lotteryService
1. Get Channel Lottery Record List
Description
获取频道抽奖记录列表(通过直播端发起抽奖)
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/lottery/list-lottery
Call Constraints
- The API call has a frequency limit. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
Unit Testing
@Test
public void testListLottery() throws Exception, NoSuchAlgorithmException {
LiveListLotteryRequest liveListLotteryRequest = new LiveListLotteryRequest();
LiveListLotteryResponse liveListLotteryResponse;
try {
liveListLotteryRequest.setChannelId(super.createChannel())
.setStartTime(super.getDate(1601481600000l))
.setEndTime(super.getDate(2021,1,21))
.setPageSize(1);
liveListLotteryResponse = new LiveLotteryServiceImpl().listLottery(liveListLotteryRequest);
Assert.assertNotNull(liveListLotteryResponse);
if (liveListLotteryResponse != null) {
//to do something ......
log.debug("测试获取频道抽奖记录列表成功,{}", JSON.toJSONString(liveListLotteryResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Testing Instructions
If the request is correct, a
LiveListLotteryResponseobject is returned, and Party B processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed fields: [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| channelId | true | String | Channel ID |
| sessionId | false | String | The live session ID to query |
| startTime | true | Date | Query start date |
| endTime | true | Date | Query end date |
| currentPage | false | Integer | Page number, defaults to 1 [Corresponds to the page field in the API documentation] |
| pageSize | false | Integer | Number of data items per page, defaults to 20 [Corresponds to the limit field in the API documentation] |
| appId | false | String | POLYV user APP_ID, required when calling with multiple accounts (i.e., when initMultiAccount() has been called to set up multi-account invocation). Obtain it by registering on the Polyv official website: Official Website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required when calling with multiple accounts (i.e., when initMultiAccount() has been called to set up multi-account invocation). Obtain it by registering on the Polyv official website: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| contents | Array | List of lottery records [See LotteryListModel Parameter Description] |
| pageSize | Integer | Number of data items displayed per page, default is 20 items per page |
| currentPage | Integer | Current page [Corresponds to the pageNumber field in the API documentation] |
| totalItems | Integer | Total number of records |
| totalPage | Integer | Total number of pages [Corresponds to the totalPages field in the API documentation] |
LotteryListModel Parameter Description
| Parameter | Type | Description |
|---|---|---|
| lotteryId | String | Lottery session ID |
| channelId | String | Channel number |
| sessionId | String | Live streaming session ID at the time of the lottery |
| lotteryRange | String | Lottery scope, values: all viewers: all; users who haven't won in the current live stream: notWinning; signed-in users: signed; title: actor; users who have completed the questionnaire: questionnaire |
| actor | String | Title when the lottery scope is based on title |
| prize | String | Prize name |
| amount | Integer | Preset number of winners |
| preset | Integer | Preset winner audience IDs, multiple IDs separated by English commas |
| createdTime | Date | Lottery creation time |
| winnerCount | Integer | Actual number of winners |
| ext | String | Additional extension information for the lottery, e.g., {"collectInfo":[{"field":"Name:","tips":"Please enter your real name"}]}, where field indicates the field name to fill in, and tips indicates the prompt for the field to fill in |
2. Retrieve Winning Records for a Single Channel Lottery Session
Description
获取频道单场抽奖的中奖记录
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/lottery/get-winner-detail
Call Constraints
- API calls are subject to rate limits. Click here for details. For common call exceptions, click here for details.
Unit Testing
@Test
public void testGetLotteryWinnerDetail() throws Exception, NoSuchAlgorithmException {
LiveLotteryWinnerDetailRequest liveLotteryWinnerDetailRequest = new LiveLotteryWinnerDetailRequest();
LiveLotteryWinnerDetailResponse liveLotteryWinnerDetailResponse;
try {
liveLotteryWinnerDetailRequest.setChannelId(super.createChannel())
.setLotteryId("fv3hogjmh3");
liveLotteryWinnerDetailResponse = new LiveLotteryServiceImpl().getLotteryWinnerDetail(
liveLotteryWinnerDetailRequest);
Assert.assertNotNull(liveLotteryWinnerDetailResponse);
if (liveLotteryWinnerDetailResponse != null) {
//to do something ......
log.debug("测试获取频道单场抽奖的中奖记录成功,{}", JSON.toJSONString(liveLotteryWinnerDetailResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Testing Instructions
If the request is correct, return a
LiveLotteryWinnerDetailResponseobject. The B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. SeePloyvSdkException.getMessage()for error details, e.g., [ Validation failed for input parameter [xxx.chat.LivexxxRequest] object, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| channelId | true | String | Channel ID |
| lotteryId | true | String | Lottery ID |
| currentPage | false | Integer | Page number, defaults to 1 [corresponds to the page field in the API documentation] |
| pageSize | false | Integer | Number of data items displayed per page, defaults to 20 [corresponds to the limit field in the API documentation] |
| appId | false | String | POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtain it by registering on the Polyv official website: Official Website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtain it by registering on the Polyv official website: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| contents | Array | Winning record list [see LotteryWinnerDetail parameter description] |
| pageSize | Integer | Number of data items displayed per page, default is 20 items per page |
| currentPage | Integer | Current page [corresponds to the pageNumber field in the API documentation] |
| totalItems | Integer | Total number of records |
| totalPage | Integer | Total number of pages [corresponds to the totalPages field in the API documentation] |
LotteryWinnerDetail Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| recordId | String | Winning record ID |
| channelId | String | Channel ID |
| sessionId | String | Live session ID at the time of the lottery |
| lotteryId | String | Lottery ID |
| viewerId | String | Winning user ID |
| viewerName | String | Winning user nickname |
| winnerCode | String | Winning code |
| prize | String | Prize name |
| createdTime | Date | Winning time |
| ext | String | Additional extension information for the lottery, e.g., {"collectInfo":[{"field":"Name:","value":"Diamond King"}]}, where field indicates the field name to fill in, and value indicates the field prompt to fill in |
3. Set Lottery Winner Information
Description
用于提交中奖者填写的信息
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/add-receive-info
Call Constraints
The API call is subject to rate limits. Click here for details. For common call exceptions, click here.
The audience's winning information can only be saved once successfully.
Winning information must be submitted and saved within 7 days, otherwise it will become invalid.
Unit Test
@Test
public void testSetLotteryWinnerInfo() throws Exception, NoSuchAlgorithmException {
LiveSetLotteryWinnerInfoRequest liveSetLotteryWinnerInfoRequest = new LiveSetLotteryWinnerInfoRequest();
Boolean liveSetLotteryWinnerInfoResponse;
try {
liveSetLotteryWinnerInfoRequest.setChannelId(super.createChannel())
.setLotteryId("fv3mao43u6")
.setWinnerCode("wMpUjVSi")
.setViewerId("asdadsdas")
.setName("sadboy")
.setTelephone("18974718689")
.setReceiveInfo("[{\"field\":\"姓名\",\"value\":\"测试\"},{\"field\":\"手机\",\"value\":\"13412345678\"}]");
liveSetLotteryWinnerInfoResponse = new LiveLotteryServiceImpl().setLotteryWinnerInfo(
liveSetLotteryWinnerInfoRequest);
Assert.assertNotNull(liveSetLotteryWinnerInfoResponse);
if (liveSetLotteryWinnerInfoResponse) {
//to do something ......
log.debug("测试设置抽奖中奖者信息成功");
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a Boolean object is returned, and the B-side processes business logic based on this object.
If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| channelId | true | String | Channel ID |
| lotteryId | true | String | Lottery session ID |
| winnerCode | true | String | Winning code |
| viewerId | true | String | Winner ID |
| name | false | String | Winner's name. If name is provided, the winner's phone number must also be provided, and the receiveInfo field is not needed (invalid). |
| telephone | false | String | Winner's phone number. If phone number is provided, the winner's name must also be provided, and the receiveInfo field is not needed (invalid). |
| receiveInfo | false | String | Custom field data, data type is array JSON [{"field":"Name","value":"Test"},{"field":"Phone","value":"13412345678"}]. field: field name, value: field value. If this parameter is provided, the name and telephone fields are not needed (invalid). |
| appId | false | String | POLYV user APP_ID. This parameter is required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtain it by registering on the Polyv official website. Path: Official website -> Login -> Live Streaming (Development Settings). |
| appSecret | false | String | POLYV user APP_SECRET. This parameter is required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtain it by registering on the Polyv official website. Path: Official website -> Login -> Live Streaming (Development Settings). |
Return Object Description
true indicates success, false indicates failure
4. Export Winning Records for a Single Channel Lottery Session
Description
用于下载频道的单场抽奖的中奖记录
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/lottery/download-winner-detail
Call Constraints
- The API call is subject to rate limits. Click here for details. For common call exceptions, click here for details.
Unit Testing
@Test
public void testDownloadLotteryDetail() throws Exception, NoSuchAlgorithmException {
LiveDownloadLotteryDetailRequest liveDownloadLotteryDetailRequest = new LiveDownloadLotteryDetailRequest();
byte[] liveDownloadLotteryDetailResponse;
try {
//path设置为下载文件路径
String path = Paths.get(getClass().getResource("/file/").toURI()).toString() + "downLoadLotteryWinner.xlsx";
liveDownloadLotteryDetailRequest.setChannelId(createChannel())
.setLotteryId("fv3hogjmh3");
liveDownloadLotteryDetailResponse = new LiveLotteryServiceImpl().downloadLotteryDetail(
liveDownloadLotteryDetailRequest);
Assert.assertNotNull(liveDownloadLotteryDetailResponse);
if (liveDownloadLotteryDetailResponse != null) {
FileUtil.writeFile(liveDownloadLotteryDetailResponse, path);
//to do something ......
log.debug("测试导出频道单场抽奖的中奖记录成功, 文件长度 {}", liveDownloadLotteryDetailResponse.length);
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Testing Instructions
If the request is correct, a
byte[]object is returned. The B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed fields [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| channelId | true | String | Channel ID |
| lotteryId | true | String | Lottery ID |
| appId | false | String | POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtained by registering on the Polyv official website: Official website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtained by registering on the Polyv official website: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
The returned byte[] can be saved according to the unit test example, or processed as needed.
5. Sending a Like
Description
用于实现用户自开发观看页点赞效果,通过调用接口可以进行点赞,默认每次请求都是一次点赞
接口地址(仅做说明使用):https://api.polyv.net/live/v2/channels/%s/like
Call Constraints
The API call is subject to rate limits. Click here for details. For common call exceptions, click here.
The interface internally implements a check, limiting each viewer to one like per second, distinguished by the submitted viewer ID.
If there is a requirement to support liking multiple items simultaneously, you can submit the optional parameter
times, with a maximum value of 30. *If the number of submissions is n, it will take n-1 seconds before you can continue liking.The
viewerIdcan be distinguished by the caller for each user.
Unit Test
@Test
public void testSendChannelLike() throws Exception, NoSuchAlgorithmException {
LiveSendChannelLikeRequest liveSendChannelLikeRequest = new LiveSendChannelLikeRequest();
Integer liveSendChannelLikeResponse;
try {
liveSendChannelLikeRequest.setChannelId(createChannel())
.setViewerId(getRandomString(16))
.setTimes(13);
liveSendChannelLikeResponse = new LiveLotteryServiceImpl().sendChannelLike(liveSendChannelLikeRequest);
Assert.assertNotNull(liveSendChannelLikeResponse);
if (liveSendChannelLikeResponse != null) {
//to do something ......
log.debug("测试发送点赞成功,{}", JSON.toJSONString(liveSendChannelLikeResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, an Integer object is returned, and the B-side processes business logic based on this object.
If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, refer to PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| channelId | true | String | Channel ID |
| viewerId | true | String | ID of the viewer giving likes, created and distinguished by the caller |
| times | false | Integer | Number of likes, cannot exceed 30. After submission, the next like can only be given after (times-1) seconds |
| appId | false | String | POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtained by registering on the Polyv official website: Official website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtained by registering on the Polyv official website: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
Number of likes
6. Sending a Tip Message
Description
用于发送打赏消息,请求成功后,服务器会向聊天室的用户广播打赏消息
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/send-reward-msg
Call Constraints
- The API call is subject to rate limits. See details. For common call exceptions, see details. The viewerId must be an online viewerId.
Unit Test
@Test
public void testSendChannelRewardMsg() throws Exception, NoSuchAlgorithmException {
LiveSendChannelRewardMsgRequest liveSendChannelRewardMsgRequest = new LiveSendChannelRewardMsgRequest();
Boolean liveSendChannelRewardMsgResponse;
try {
liveSendChannelRewardMsgRequest.setChannelId(createChannel())
.setNickname("sadboy")
.setAvatar("https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3002379740,3965499425&fm=26&gp=0.jpg")
.setDonateType("cash")
.setContent("1")
.setGoodImage("https://s1.videocc.net/live-admin/img/icon-redpack-new.ae299535.png")
.setSessionId(null)
.setGoodNum("1")
.setNeedUserImage("N")
//通过外部授权等观看方式对接,由B端系统产生,通过白名单进入的,此处可使用会员码
.setViewerId(getRandomString(16));
liveSendChannelRewardMsgResponse = new LiveLotteryServiceImpl().sendChannelRewardMsg(
liveSendChannelRewardMsgRequest);
Assert.assertTrue(liveSendChannelRewardMsgResponse);
if (liveSendChannelRewardMsgResponse) {
//to do something ......
log.debug("测试发送打赏消息成功");
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a Boolean object is returned. The B-side handles business logic based on this object.
If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found inPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| channelId | true | String | Channel ID |
| nickname | true | String | Donor's nickname |
| avatar | true | String | Donor's avatar |
| viewerId | true | String | Donor's ID, generated by the B-end system for external authorization viewing methods. If entering via a whitelist, the membership code can be used here. |
| donateType | true | String | Donation type (cash: cash donation; good: item donation) |
| content | true | String | Donation content: gift name for item donations, amount for cash donations |
| goodImage | false | String | Gift image for item donations; empty for cash donations |
| sessionId | false | String | Live streaming session ID |
| goodNum | false | String | Number of donations; defaults to 1 if not provided |
| needUserImage | false | String | Whether the socket message requires the user's image (Y: yes, N: no; defaults to N if not provided) |
| appId | false | String | POLYV user APP_ID. Required when calling with multiple accounts (i.e., after calling initMultiAccount() to set up multi-account calls). Obtain by registering on the POLYV official website: Official Website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET. Required when calling with multiple accounts (i.e., after calling initMultiAccount() to set up multi-account calls). Obtain by registering on the POLYV official website: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
true indicates successful sending, false indicates failed sending.
7. Query Channel Winning Statistics Records
Description
查询频道中奖统计记录
接口地址(仅做说明使用):https://api.polyv.net/live/v4/channel/lottery/list
Call Constraints
The API call is subject to rate limits. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
When
lotteryIdis not provided,startTimeandendTimeare required.When
lotteryIdis passed,startTimeandendTimeare optional. Even if they are provided, they will not take effect.The maximum query time span for startTime and endTime is 365 days.
Unit Test
@Test
public void testGetLotteryList() throws IOException, NoSuchAlgorithmException {
LiveGetLotteryListRequest liveGetLotteryListRequest = new LiveGetLotteryListRequest();
LiveGetLotteryListResponse liveGetLotteryListResponse;
try {
String channelId = createChannel();
liveGetLotteryListRequest.setChannelId(channelId)
.setStartTime(super.getXDay(new Date(), -60))
.setEndTime(super.getDate(System.currentTimeMillis()));
liveGetLotteryListResponse = new LiveLotteryServiceImpl().getLotteryList(liveGetLotteryListRequest);
Assert.assertNotNull(liveGetLotteryListResponse);
if (liveGetLotteryListResponse != null) {
//to do something ......
log.debug("测试查询频道中奖统计记录成功 {}", JSON.toJSONString(liveGetLotteryListResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a LiveGetLotteryListResponse object is returned, and Party B processes business logic based on this object.
If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed fields [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| channelId | true | String | Channel ID |
| lotteryId | false | String | Lottery ID |
| sessionId | false | String | Session ID |
| startTime | false | Date | Start time, 13-digit millisecond timestamp |
| endTime | false | Date | End time, 13-digit millisecond timestamp |
| currentPage | false | Integer | Page number, defaults to 1 [corresponds to the pageNumber field in the API documentation] |
| pageSize | false | Integer | Number of data entries displayed per page, defaults to 20 entries per page |
| appId | false | String | POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtained by registering on the Polyv official website: Official website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtained by registering on the Polyv official website: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| contents | Array | List of winning records [See LotteryListContents Parameter Description] |
| pageSize | Integer | Number of data items displayed per page, default is 20 items per page |
| currentPage | Integer | Current page [Corresponds to the pageNumber field in the API documentation] |
| totalItems | Integer | Total number of records |
| totalPage | Integer | Total number of pages [Corresponds to the totalPages field in the API documentation] |
LotteryListContents Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| winnerCount | Integer | Actual number of winners |
| totalUsers | Integer | Number of participants in the lottery |
| lotteryId | String | Lottery session ID |
| channelId | String | Channel ID |
| userId | String | Account user ID |
| sessionId | String | Live session ID at the time of the lottery |
| lotteryRange | String | Range of lottery candidates |
| actor | String | Title name when drawing by title |
| prize | String | Prize name |
| amount | Integer | Number of winners |
| preset | String | Preset winners, separated by commas |
| lotteryExt | LotteryListExt | Additional extension information for the lottery see LotteryListExt parameter description |
| createdTime | Date | Lottery creation time |
LotteryListExt Parameter Description
| Parameter | Type | Description |
|---|---|---|
| collectInfo | Array | List of prize collection information for winning users [See LotteryListExtCollectInfo Parameter Description] |
LotteryListExtCollectInfo Parameter Description
| Parameter | Type | Description |
|---|---|---|
| field | String | Field name |
| tips | String | Input hint |
8. Query Lottery Records for Multiple Channels
Description
获取一段时间内的多个直播频道发起抽奖记录列表
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/lottery/list-channels-lottery
Call Constraints
- The API call is subject to rate limits. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
Unit Testing
@Test
public void testListChannelsLottery() throws IOException, NoSuchAlgorithmException {
LiveListChannelsLotteryRequest liveListChannelsLotteryRequest = new LiveListChannelsLotteryRequest();
LiveListChannelsLotteryResponse liveListChannelsLotteryResponse;
try {
String channelId = super.createChannel();
liveListChannelsLotteryRequest.setChannelIds(channelId);
liveListChannelsLotteryRequest.setStartTime(super.getDate(1601481600000L));
liveListChannelsLotteryRequest.setEndTime(super.getDate(1615357743000L));
liveListChannelsLotteryResponse = new LiveLotteryServiceImpl().listChannelsLottery(
liveListChannelsLotteryRequest);
Assert.assertNotNull(liveListChannelsLotteryResponse);
if (liveListChannelsLotteryResponse != null) {
//to do something ......
log.debug("测试查询多个频道抽奖记录成功 {}", JSON.toJSONString(liveListChannelsLotteryResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Testing Instructions
If the request is correct, a
LiveListChannelsLotteryResponseobject is returned, and the B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. SeePloyvSdkException.getMessage()for error details, e.g., [ Validation failed for input parameter [xxx.chat.LivexxxRequest] object, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| channelIds | true | String | Channel IDs, multiple channels separated by "," |
| startTime | true | Date | Query start date |
| endTime | true | Date | Query end date |
| sessionId | false | String | Live session ID to query; defaults to all sessions in the channel |
| currentPage | false | Integer | Page number, defaults to 1 (corresponds to the page field in the API documentation) |
| pageSize | false | Integer | Number of data items per page, defaults to 20 (corresponds to the limit field in the API documentation) |
| appId | false | String | POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtain it by registering on the POLYV official website: Official Website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtain it by registering on the POLYV official website: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| contents | Array | List of lottery records [See LotteryListModel Parameter Description] |
| pageSize | Integer | Number of data items displayed per page, default is 20 items per page |
| currentPage | Integer | Current page [Corresponds to the pageNumber field in the API documentation] |
| totalItems | Integer | Total number of records |
| totalPage | Integer | Total number of pages [Corresponds to the totalPages field in the API documentation] |
LotteryListModel Parameter Description
| Parameter | Type | Description |
|---|---|---|
| lotteryId | String | Lottery session ID |
| channelId | String | Channel number |
| sessionId | String | Live streaming session ID at the time of the lottery |
| userId | String | Account user ID |
| lotteryRange | String | Lottery scope: all - all viewers, notWinning - viewers who did not win in the current live stream, signed - signed-in users, actor - by title, questionnaire - users who completed the questionnaire |
| actor | String | Title used when the lottery scope is by title |
| prize | String | Prize name |
| amount | Integer | Preset number of winners |
| preset | String | Preset winner audience IDs, multiple IDs separated by commas |
| createdTime | Date | Lottery creation time |
| lastModified | Date | Last modification time |
| winnerCount | String | Actual number of winners |
| ext | String | JSON format string representing additional lottery extension information, corresponding to the model class: LotteryListModelExt field description |
