chatRoomService
1. Batch Import Channel Prohibited Words
Description
批量导入频道严禁词
接口地址(仅做说明使用):https://api.polyv.net/live/v2/chat/%s/addBadWords
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 testAddBadWord() throws Exception, NoSuchAlgorithmException {
LiveBadWordRequest liveBadWordRequest = new LiveBadWordRequest();
LiveBadWordResponse liveBadWordResponse = null;
try {
String channelId = super.createChannel();
liveBadWordRequest.setChannelId(channelId).setWords(Arrays.asList(new String[]{"微信号", "手机号", "QQ号"}));
liveBadWordResponse = new LiveChatRoomServiceImpl().addBadWord(liveBadWordRequest);
Assert.assertNotNull(liveBadWordResponse);
if (liveBadWordResponse != null) {
//to do something ......
log.debug("测试批量导入频道严禁词成功{}", JSON.toJSONString(liveBadWordResponse));
}
} 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 Description
If the request is correct, a
LiveBadWordResponseobject is returned, and the B-side processes the 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 | false | String | Channel ID. If not provided, the forbidden words from the general settings will be used. |
| words | true | Array | List of forbidden words. |
| userId | false | String | POLYV user ID. This parameter is 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). |
| 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 invocation). Obtain it by registering on the Polyv official website: 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 invocation). Obtain it by registering on the Polyv official website: Official Website -> Login -> Live Streaming (Development Settings). |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| count | Integer | If the request parameter sets a channel ID, count is the number of prohibited words in that channel; if no channel ID is set, count is the number of prohibited words for the account. |
| userId | String | POLYV user ID, obtained by registering on the Polyv official website. Path: Official website -> Login -> Live Streaming (Developer Settings) |
2. Query Historical Chat Information
Description
查询一段时间内的聊天记录,时间格式为yyyy-MM-dd 或 yyyy-MM-dd HH:mm:ss。如未提交具体时间,只提交了日期,开始时间默认为日期当天的 00:00:00,结束时间为日期当天的23:59:59
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/get-history-page
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 testGetHistoryChatMsg() throws Exception, NoSuchAlgorithmException {
LiveGetMessageListRequest liveGetMessageListRequest = new LiveGetMessageListRequest();
LiveGetMessageListResponse liveGetMessageListResponses;
try {
String channelId = super.createChannel();
liveGetMessageListRequest.setChannelId(channelId)
.setStartDay(getDate(2020, 10, 01))
.setEndDay(getDate(2099, 12, 12))
.setStatus("pass")
.setPageSize(5)
.setCurrentPage(3);
liveGetMessageListResponses = new LiveChatRoomServiceImpl().getPageHistoryChatMsg(
liveGetMessageListRequest);
Assert.assertNotNull(liveGetMessageListResponses);
if (liveGetMessageListResponses != null) {
//to do something ......
log.debug("测试查询历史聊天信息成功{}", JSON.toJSONString(liveGetMessageListResponses));
}
} 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
LiveGetMessageListResponseobject 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 |
|---|---|---|---|
| startDay | true | Date | The start time of the chat history, in the format yyyy-MM-dd, e.g., 2021-03-01, or yyyy-MM-dd HH:mm:ss, e.g., 2021-03-01 16:30:12 |
| endDay | true | Date | The end time of the chat history, same format requirements as above |
| channelId | true | String | Channel ID |
| userType | false | String | User type, multiple types can be selected, separated by commas: slice: Polyv Cloud Classroom student, teacher: instructor, guest: guest, manager: manager, assistant: teaching assistant, viewer: special guest, monitor: stage monitor, attendee: seminar participant, student: general live stream viewer |
| status | false | String | Chat history review status, default is pass: reviewed, pass: reviewed, censor: under review and deleted |
| source | false | String | Type, default is public chat if not filled; extend: admin private chat |
| roomId | false | String | If a room ID exists, it must be provided; default is not provided |
| hasTotal | false | String | Whether to return the total count of the current query, Y: Yes, N: No, default is N. Note: Only valid when querying the first page. This parameter may affect API response performance. It is recommended not to pass this parameter unless strongly needed. You can determine if there is a next page based on the length of the contents array in the response. |
| currentPage | false | Integer | Page number, default is 1 (corresponds to the page field in the API documentation) |
| pageSize | false | Integer | Number of data items displayed per page, default is 20 items 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). 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 calls). Obtain it by registering on the Polyv official website: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| contents | Array | Query result list [See MessageList parameter description] |
| pageSize | Integer | Number of data items displayed per page, default is 20 |
| 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] |
MessageList Parameter Description
| Parameter | Type | Description |
|---|---|---|
| id | String | Chat message ID |
| accountId | String | Account ID |
| clientIP | String | User IP address |
| content | String | Chat content |
| event | String | Event, refer to the chat room SDK for details |
| image | String | Image URL for image messages |
| msgType | String | Message type: redpaper (red envelope message), get_redpaper (red envelope claim message), chatImg (image message), custom (custom message sent via socket), reward (tip message), customerMessage (custom message sent via HTTP interface), empty (regular chat message) |
| quote | String | Quoted content |
| sessionId | String | Session ID |
| roomId | String | Room ID |
| channelId | String | Channel ID |
| time | Date | Time when the message was sent |
| userType | String | User type: slice (cloud classroom student), teacher (instructor), guest (guest), manager (administrator), assistant (teaching assistant), viewer (special audience), monitor (session monitor), attendee (seminar participant), student (regular live stream viewer) |
| status | String | Review status: pass (approved), censor (under review), delete (deleted) |
| sourceType | String | Message source: public (group chat), extend (administrator private chat) |
| user | MessageListUser | Chat information array [See MessageListUser Parameter Description for details] |
MessageListUser Parameter Description
| Parameter | Type | Description |
|---|---|---|
| actor | String | Role |
| banned | Boolean | Whether muted |
| channelId | String | Channel ID |
| clientIp | String | User IP |
| nickname | String | Viewer nickname |
| pic | String | Viewer avatar |
| roomId | String | Room ID |
| sessionId | String | Session ID |
| uid | String | Socket ID |
| userId | String | Unique user identifier |
| userSource | String | Viewer source |
| userType | String | User type: slice - cloud classroom student, teacher - lecturer, guest - guest, manager - manager, assistant - teaching assistant, viewer - invited viewer, monitor - session monitor, attendee - seminar participant, student - regular live stream viewer |
| param4 | String | Custom user field |
| param5 | String | Custom user field |
3. Query Chat Room Administrator Information
Description
查询聊天室管理员信息
接口地址(仅做说明使用):https://api.polyv.net/live/v2/channelSetting/%s/get-chat-admin
Call Constraints
- The API call has a frequency limit. For details, see [/live/java/limit.md]. For common call exceptions, see [/live/java/exceptionDoc].
Unit Testing
@Test
public void testGetChatAdminData() throws Exception, NoSuchAlgorithmException {
LiveGetChatAdminDataRequest liveGetChatAdminDataRequest = new LiveGetChatAdminDataRequest();
LiveGetChatAdminDataResponse liveGetChatAdminDataResponse = null;
try {
String channelId = super.createChannel();
liveGetChatAdminDataRequest.setChannelId(channelId);
liveGetChatAdminDataResponse = new LiveChatRoomServiceImpl().getChatAdminData(liveGetChatAdminDataRequest);
Assert.assertNotNull(liveGetChatAdminDataResponse);
if (liveGetChatAdminDataResponse != null) {
//to do something ......
log.debug("测试查询聊天室管理员信息成功{}", JSON.toJSONString(liveGetChatAdminDataResponse));
}
} 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 Description
If the request is correct, it returns a
LiveGetChatAdminDataResponseobject, based on which the B-side processes business logic.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, refer to 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 |
| appId | false | String | POLYV user APP_ID. This parameter is required for multi-account calls (i.e., when initMultiAccount() has been called to set up multi-account invocation). 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() has been called to set up multi-account invocation). Obtain it by registering on the POLYV official website. Path: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| nickname | String | Lecturer nickname |
| actor | String | Lecturer title |
| avatar | String | Avatar image URL |
| appId | 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 | 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) |
4. Query Channel Mute List
Description
查询频道禁言列表
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/get-banned-list
Call Constraints
Unit Testing
@Test
public void testGetBannedList() throws Exception, NoSuchAlgorithmException {
LiveGetBannedListRequest liveGetBannedListRequest = new LiveGetBannedListRequest();
List<String> liveGetBannedListResponseList = null;
try {
String channelId = super.createChannel();
liveGetBannedListRequest.setChannelId(channelId).setType(LiveConstant.BannedType.IP.getType());
liveGetBannedListResponseList = new LiveChatRoomServiceImpl().getBannedList(liveGetBannedListRequest);
Assert.assertNotNull(liveGetBannedListResponseList);
if (liveGetBannedListResponseList != null) {
//to do something ......
log.debug("测试查询频道禁言列表成功{}", JSON.toJSONString(liveGetBannedListResponseList));
}
} 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 String 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 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 |
| type | true | String | Type of mute query, ip: machine IP of the chat room user, userId: userId of the chat room user |
| toGetSubRooms | false | Integer | Whether to retrieve the mute list of sub-rooms, 0: do not retrieve, 1: retrieve, default is 0 |
| appId | false | String | POLYV user APP_ID, required when calling with multiple accounts (i.e., when initMultiAccount() is invoked for multi-account setup). 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() is invoked for multi-account setup). Obtain it by registering on the Polyv official website: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
The return object is a List<String>, where each String element contains the following content:
Returns the mute list of the current channel
5. Query Channel Kick List
Description
查询频道踢人列表
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/list-kicked
Call Constraints
- The API call is subject to rate limits. For details, see here. For common call exceptions, see here.
Unit Testing
@Test
public void testGetKickedList() throws Exception, NoSuchAlgorithmException {
LiveKickedListRequest liveKickedListRequest = new LiveKickedListRequest();
List<LiveKickedListResponse> liveKickedListResponsesList = null;
try {
String channelId = super.createChannel();
liveKickedListRequest.setChannelId(channelId);
liveKickedListResponsesList = new LiveChatRoomServiceImpl().getKickedList(liveKickedListRequest);
Assert.assertNotNull(liveKickedListResponsesList);
if (liveKickedListResponsesList != null) {
//to do something ......
log.debug("测试查询频道踢人列表成功{}", JSON.toJSONString(liveKickedListResponsesList));
}
} 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
LiveKickedListResponseobject. 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, 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 |
| 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 invocation). 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 invocation). Obtain it by registering on the POLYV official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
The return object is List<LiveKickedListResponse>. The specific element content of LiveKickedListResponse is as follows:
| Parameter | Type | Description |
|---|---|---|
| banned | Boolean | Whether the user is muted |
| channelId | String | Channel ID |
| clientIp | String | Client-side viewer IP |
| kickRefer | String | Kick method: userId (user ID), ip (user login IP) |
| nickname | String | Nickname (corresponds to the nick field in the API documentation) |
| pic | String | Avatar image URL |
| roomId | String | Room ID |
| uid | String | Chat room socket ID |
| userId | String | Client-side viewer ID |
| userType | String | User role: manager (admin), teacher (instructor), assistant (teaching assistant), guest (guest), viewer (participant), slice/student (observer/student) |
6. Query Channel Banned Words/Banned IP List
Description
接口用于获取频道的严禁词或者禁言IP列表
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/badword/list
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 testGetChannelBadworkList() throws Exception, NoSuchAlgorithmException {
LiveGetBadwordIPRequest liveGetBadwordIPRequest = new LiveGetBadwordIPRequest();
List<String> liveGetBadwordIPResponseList = null;
try {
String channelId = super.createChannel();
liveGetBadwordIPRequest.setChannelId(channelId).setType(LiveConstant.BannedType.IP.getType());
liveGetBadwordIPResponseList = new LiveChatRoomServiceImpl().getChannelBadworkList(liveGetBadwordIPRequest);
Assert.assertNotNull(liveGetBadwordIPResponseList);
if (liveGetBadwordIPResponseList != null) {
//to do something ......
log.debug("测试查询频道严禁词/禁言IP列表成功{}", JSON.toJSONString(liveGetBadwordIPResponseList));
}
} 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 String 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 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 |
| type | false | String | Query type: ip=IP mute, badword=prohibited words, default is badword |
| appId | false | String | POLYV user APP_ID, 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: 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). Obtain it by registering on the Polyv official website: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
The return object is List<String>, where each String element contains the following content:
Retrieve the list of prohibited words/muted IPs for the current channel.
7. Query the List of Prohibited Words for Accounts
Description
接口用于获取账号下通用设置的严禁词列表
接口地址(仅做说明使用):https://api.polyv.net/live/v3/user/badword/list
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 testGetAccountBadworkList() throws Exception, NoSuchAlgorithmException {
LiveGetAccountBadWordRequest liveGetAccountBadWordRequest = new LiveGetAccountBadWordRequest();
List<String> liveGetAccountBadWordResponseList = null;
try {
liveGetAccountBadWordResponseList = new LiveChatRoomServiceImpl().getAccountBadworkList(
liveGetAccountBadWordRequest);
Assert.assertNotNull(liveGetAccountBadWordResponseList);
if (liveGetAccountBadWordResponseList != null) {
//to do something ......
log.debug("测试查询账号严禁词列表成功{}", JSON.toJSONString(liveGetAccountBadWordResponseList));
}
} 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 String 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 Name | Required | Type | Description |
|---|---|---|---|
| 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
The return object is a List<String>, where each String element contains the following:
The list of prohibited words in the general settings under the current Polyv account.
8. Query Consultation Question Records
Description
查询咨询提问记录
接口地址(仅做说明使用):https://api.polyv.net/live/v2/chat/%s/getQuestion
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 testGetConsultingRecord() throws Exception, NoSuchAlgorithmException {
LiveGetConsultingRecordRequest liveGetConsultingRecordRequest = new LiveGetConsultingRecordRequest();
List<LiveGetConsultingRecordResponse> liveGetConsultingRecordResponseList = null;
try {
String channelId = super.createChannel();
liveGetConsultingRecordRequest.setChannelId(channelId).setBegin(0).setEnd(10);
liveGetConsultingRecordResponseList = new LiveChatRoomServiceImpl().getConsultingRecord(
liveGetConsultingRecordRequest);
Assert.assertNotNull(liveGetConsultingRecordResponseList);
if (liveGetConsultingRecordResponseList != null) {
//to do something ......
log.debug("测试查询咨询提问记录成功{}", JSON.toJSONString(liveGetConsultingRecordResponseList));
}
} 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
LiveGetConsultingRecordResponseobject 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 | Required | Type | Description |
|---|---|---|---|
| channelId | true | String | Channel ID |
| begin | false | Integer | Start index, starting from 0 |
| end | false | Integer | End index, -1 indicates no pagination |
| appId | false | String | POLYV user APP_ID, 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: 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). Obtain it by registering on the POLYV official website: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
The return object is List<LiveGetConsultingRecordResponse>. The specific elements of LiveGetConsultingRecordResponse are as follows:
| Parameter | Type | Description |
|---|---|---|
| id | String | Message ID |
| content | String | Content |
| time | Date | Time of the message |
| user | User | Speaker information [see User parameter description] |
| event | String | Message type, instructor answer: T_ANSWER, student question: S_QUESTION |
| userId | String | Questioner ID [corresponds to the s_userId field in the API documentation] |
User Parameter Description
| Parameter | Type | Description |
|---|---|---|
| nick | String | Viewer nickname |
| pic | String | Viewer avatar |
| userId | String | Unique user identifier |
| sessionId | String | Session ID |
| channelId | String | Channel ID |
| banned | Boolean | Whether muted true: muted false: not muted |
| userType | String | User type, currently includes teacher, assistant, manager, slice (cloud classroom student) |
9. Setting Instructor Information
Description
设置讲师信息
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/account/updateTeacher
Call Constraints
- The API call has a frequency limit. Click here for details. For common call exceptions, click here for details.
Unit Testing
@Test
public void testSetChannelTeacherMsg() throws Exception, NoSuchAlgorithmException {
LiveSetTeacherDataRequest liveSetTeacherDataRequest = new LiveSetTeacherDataRequest();
Boolean liveSetTeacherDataResponse = null;
try {
String channelId = super.createChannel();
liveSetTeacherDataRequest.setChannelId(channelId)
.setNickname("讲师张三")
.setActor("教授")
.setPasswd("123456")
.setAvatar("https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3002379740," +
"3965499425&fm=26&gp=0" + ".jpg");
liveSetTeacherDataResponse = new LiveChatRoomServiceImpl().setChannelTeacherMsg(liveSetTeacherDataRequest);
Assert.assertNotNull(liveSetTeacherDataResponse);
if (liveSetTeacherDataResponse != null) {
//to do something ......
log.debug("测试设置讲师信息成功{}", JSON.toJSONString(liveSetTeacherDataResponse));
}
} 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 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 |
| nickname | false | String | Instructor nickname |
| actor | false | String | Instructor title |
| passwd | false | String | Channel password, length <= 16, must contain both letters and numbers |
| avatar | false | String | Avatar image URL; if empty, the default avatar is used |
| 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 invocation). Obtain it by registering on the Polyv official website: 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 invocation). Obtain it by registering on the Polyv official website: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
true indicates the instructor information was set successfully, false indicates the instructor information failed to be set.
10. Set Chat Room IP Mute
Description
设置聊天室禁言ip
接口地址(仅做说明使用):https://api.polyv.net/live/v2/chat/%s/addBannedIP
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 testAddBannedIP() throws Exception, NoSuchAlgorithmException {
LiveChatBannedIPRequest liveChatBannedIPRequest = new LiveChatBannedIPRequest();
List<String> liveChatBannedIPResponseList = null;
try {
String channelId = super.createChannel();
liveChatBannedIPRequest.setIp("192.168.1.1").setChannelId(channelId);
liveChatBannedIPResponseList = new LiveChatRoomServiceImpl().addBannedIP(liveChatBannedIPRequest);
Assert.assertNotNull(liveChatBannedIPResponseList);
if (liveChatBannedIPResponseList != null) {
//to do something ......
log.debug("测试设置聊天室禁言ip成功{}", JSON.toJSONString(liveChatBannedIPResponseList));
}
} 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 String 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 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 |
| ip | true | String | Muted IP, e.g., 234.22.3.34 |
| 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
The return object is a List<String>, where each String element contains the following:
The current list of all muted IPs.
11. Set Chat Room Administrator Information
Description
设置聊天室管理员信息
接口地址(仅做说明使用):https://api.polyv.net/live/v2/channelSetting/%s/set-chat-admin
Call Constraints
- The API call is subject to rate limits. For details, see here. For common call exceptions, see here.
Unit Testing
@Test
public void testSetChatAdminData() throws Exception, NoSuchAlgorithmException, URISyntaxException {
LiveSetChatAdminDataRequest liveSetChatAdminDataRequest = new LiveSetChatAdminDataRequest();
Boolean liveSetChatAdminDataResponse = null;
try {
String channelId = super.createChannel();
String path = getClass().getResource("/img/b.jpg").getPath();
liveSetChatAdminDataRequest.setChannelId(channelId)
.setNickname("管理员赵四")
.setActor("管理员")
.setAvatar(new File(path));
liveSetChatAdminDataResponse = new LiveChatRoomServiceImpl().setChatAdminData(liveSetChatAdminDataRequest);
Assert.assertTrue(liveSetChatAdminDataResponse);
if (liveSetChatAdminDataResponse != null) {
//to do something ......
log.debug("测试设置聊天室管理员信息成功{}", JSON.toJSONString(liveSetChatAdminDataResponse));
}
} 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 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 |
| nickname | true | String | Admin nickname, must not exceed 8 characters |
| actor | true | String | Admin title, must not exceed 4 characters |
| avatar | true | File | Admin avatar, supports jpg, jpeg, and png formats, size must not exceed 2Mb |
| appId | false | String | POLYV user APP_ID, 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: 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). Obtain it by registering on the Polyv official website: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
true indicates success, false indicates failure
12. Delete Muted IP / Banned Words
Description
删除禁言IP/严禁词
接口地址(仅做说明使用):https://api.polyv.net/live/v2/chat/%s/delBanned
Call Constraints
- The API call has a frequency limit. Click here for details. For common call exceptions, click here for details.
Unit Testing
@Test
public void testDelBanned() throws Exception, NoSuchAlgorithmException {
LiveDelBannedDataRequest liveDelBannedDataRequest = new LiveDelBannedDataRequest();
Boolean liveDelBannedDataResponse = null;
try {
//创建一个禁言IP(192.168.1.1)用于测试,实际业务过程中,此代码可以删除
testAddBannedIP();
//正式业务逻辑
String channelId = super.createChannel();
liveDelBannedDataRequest.setContent("192.168.1.1")
.setChannelId(channelId)
.setType(LiveConstant.BannedType.IP.getType());
liveDelBannedDataResponse = new LiveChatRoomServiceImpl().delBanned(liveDelBannedDataRequest);
Assert.assertNotNull(liveDelBannedDataResponse);
if (liveDelBannedDataResponse != null) {
//to do something ......
log.debug("测试删除禁言IP/严禁词成功{}", JSON.toJSONString(liveDelBannedDataResponse));
}
} 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 Boolean 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, 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 |
| type | true | String | Type of transmitted content ip: The content attribute value is an IP badword: The content attribute value is a prohibited word |
| content | true | String | The IP or prohibited word to be removed. Supports passing multiple IPs or prohibited words, separated by "," |
| appId | false | String | POLYV user APP_ID. This parameter is required for multi-account calls (i.e., when initMultiAccount() has been called to set up multi-account calls). Obtained 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() has been called to set up multi-account calls). Obtained by registering on the Polyv official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
true indicates successful deletion, false indicates failed deletion.
13. Delete a Single Chat Record
Description
根据聊天的id删除对应聊天记录
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/send-admin-msg
Call Constraints
- The API call is subject to rate limits. For details, see [/live/java/limit.md]. For common call exceptions, see [/live/java/exceptionDoc].
Unit Testing
@Test
public void testDelChatSingleMsg() throws Exception, NoSuchAlgorithmException {
LiveChatDelSingleMsgRequest liveChatDelSingleMsgRequest = new LiveChatDelSingleMsgRequest();
Boolean liveChatDelSingleMsgResponse = null;
String channelId = super.createChannel();
//获取已经存在的消息id
//new LiveChatRoomServiceImpl().sendChatMsg(liveSendChatMsgRequest)
String msgId = getMsgId(channelId);
try {
liveChatDelSingleMsgRequest.setId(msgId).setChannelId(channelId);
liveChatDelSingleMsgResponse = new LiveChatRoomServiceImpl().delChatSingleMsg(liveChatDelSingleMsgRequest);
Assert.assertNotNull(liveChatDelSingleMsgResponse);
if (liveChatDelSingleMsgResponse != null) {
//to do something ......
log.debug("测试删除单条聊天记录成功{}", JSON.toJSONString(liveChatDelSingleMsgResponse));
}
} 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 Boolean 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 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 |
| id | true | String | ID corresponding to the chat record |
| appId | false | String | POLYV user APP_ID, 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: 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). Obtain it by registering on the Polyv official website: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
true indicates successful deletion, false indicates deletion failure
14. Delete Channel Chat History
Description
删除频道聊天记录
接口地址(仅做说明使用):https://api.polyv.net/live/v2/chat/%s/cleanChat
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 testCleanChannelAllMsg() throws Exception, NoSuchAlgorithmException {
LiveCleanChannelAllMsgRequest liveCleanChannelAllMsgRequest = new LiveCleanChannelAllMsgRequest();
Boolean liveCleanChannelAllMsgResponse = null;
try {
String channelId = super.createChannel();
liveCleanChannelAllMsgRequest.setChannelId(channelId);
liveCleanChannelAllMsgResponse = new LiveChatRoomServiceImpl().cleanChannelAllMsg(
liveCleanChannelAllMsgRequest);
Assert.assertNotNull(liveCleanChannelAllMsgResponse);
if (liveCleanChannelAllMsgResponse != null) {
//to do something ......
log.debug("测试删除频道聊天记录成功{}", JSON.toJSONString(liveCleanChannelAllMsgResponse));
}
} 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 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 inPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encounters an exception and throws 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 |
| 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 invocation). 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 invocation). Obtain it by registering on the POLYV official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
true indicates successful deletion, false indicates failed deletion
15. Admin Sends Channel Chat Message
Description
管理员发送频道聊天信息
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/send
Call Constraints
- The API call is subject to rate limits. For details, see here. For common call exceptions, see here.
Unit Testing
@Test
public void testSendChannelChat() throws Exception, NoSuchAlgorithmException {
LiveSendChannelChatRequest liveSendChannelChatRequest = new LiveSendChannelChatRequest();
Boolean liveSendChannelChatResponse;
try {
String channelId = super.createChannel();
liveSendChannelChatRequest.setChannelId(channelId).setContent("请同学们认真学习").setRole("ADMIN");
liveSendChannelChatResponse = new LiveChatRoomServiceImpl().sendChannelChat(liveSendChannelChatRequest);
Assert.assertTrue(liveSendChannelChatResponse);
if (liveSendChannelChatResponse) {
//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 Testing Instructions
If the request is correct, a Boolean 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 |
| content | true | String | Chat message content |
| role | true | String | Sender role (currently only the admin role is provided, with the value 'ADMIN') |
| 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 successful sending, false indicates failed sending
16. Sending Custom Chat Messages
Description
聊天室发送系统消息
接口地址(仅做说明使用):https://api.polyv.net/live/v1/channelSetting/%s/send-chat
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 testSendCustomChat() throws Exception, NoSuchAlgorithmException {
LiveSendCustomChatRequest liveSendCustomChatRequest = new LiveSendCustomChatRequest();
Boolean liveSendCustomChatResponse;
try {
String channelId = super.createChannel();
liveSendCustomChatRequest.setChannelId(channelId).setContent("请同学们认真学习");
liveSendCustomChatResponse = new LiveChatRoomServiceImpl().sendCustomChatV2(liveSendCustomChatRequest);
Assert.assertTrue(liveSendCustomChatResponse);
if (liveSendCustomChatResponse) {
//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 Testing Instructions
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 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 |
| userId | false | String | POLYV user ID. This parameter is required for multi-account calls (i.e., when initMultiAccount() has been called to set up multi-account calls). Obtain it by registering on the POLYV official website: Official Website -> Login -> Live Streaming (Development Settings) |
| content | false | String | Text to be sent (set the value directly; base64 encoding is prohibited). content and imgUrl cannot both be empty, but they can be submitted together. |
| imgUrl | false | String | Image to be sent. content and imgUrl cannot both be empty, but they can be submitted together. |
| appId | false | String | POLYV user APP_ID. This parameter is required for multi-account calls (i.e., when initMultiAccount() has been called to set up multi-account calls). Obtain it by registering on the POLYV official website: 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() has been called to set up multi-account calls). Obtain it 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
17. Sending Custom Messages
Description
发送聊天室自定义消息
接口地址(仅做说明使用):https://api.polyv.net/live/v4/chat/send-custom-message
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].
The text content (
content) or image (imgUrl) to be sent cannot both be empty, but they can be submitted simultaneously.
Unit Test
@Test
public void testSendCustomMessage() throws IOException, NoSuchAlgorithmException {
LiveSendCustomMessageRequest liveSendCustomMessageRequest = new LiveSendCustomMessageRequest();
Boolean liveSendCustomMessageResponse;
try {
String channelId = super.createChannel();
liveSendCustomMessageRequest.setChannelId(channelId).setContent("请同学们认真学习,天天向上!").setJoinHistoryList(0);
liveSendCustomMessageResponse = new LiveChatRoomServiceImpl().sendCustomMessage(
liveSendCustomMessageRequest);
Assert.assertTrue(liveSendCustomMessageResponse);
if (liveSendCustomMessageResponse) {
//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 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 |
| content | false | String | Text content to send |
| imgUrl | false | String | URL of the image to send |
| joinHistoryList | false | Integer | Whether to include in chat history data, default is 1. 1: Include in chat history data, 0: Do not include |
| watchType | false | Integer | The role(s) this message is intended for (default is 1, supports multiple selections, e.g., 45) 1: All roles in the channel 2: Only audience roles in the channel 3: Only special roles (lecturer, guest, teaching assistant, administrator) 4: Lecturer 5: Guest 6: Teaching assistant 7: Administrator |
| important | false | String | Whether it is an important message, default is N Y: Important message N: Normal message. When important is Y, the API request frequency is limited to a maximum of 30 requests per minute per channel, ensuring messages are not lost and there is no severe delay. |
| appId | false | String | POLYV user APP_ID, 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, 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
Custom Message Return Entity
18. Delete Account Prohibited Words
Description
删除账号通用设置的严禁词,支持批量删除多个严禁词
接口地址(仅做说明使用):https://api.polyv.net/live/v3/user/badword/delete
Call Constraints
- The API call is subject to frequency 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 testDeleteUserBadword() throws IOException, NoSuchAlgorithmException {
LiveDeleteUserBadwordRequest liveDeleteUserBadwordRequest = new LiveDeleteUserBadwordRequest();
List<String> liveDeleteUserBadwordResponse;
try {
String words = "中南";
liveDeleteUserBadwordRequest.setWords(words);
liveDeleteUserBadwordResponse = new LiveChatRoomServiceImpl().deleteUserBadword(
liveDeleteUserBadwordRequest);
Assert.assertNotNull(liveDeleteUserBadwordResponse);
if (liveDeleteUserBadwordResponse != null) {
//to do something ......
log.debug("测试删除账号严禁词成功 {}", JSON.toJSONString(liveDeleteUserBadwordResponse));
}
} 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 String object 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 | Required | Type | Description |
|---|---|---|---|
| words | true | String | The prohibited words to be deleted, separated by English commas. For example: prohibited_word1,prohibited_word2 |
| 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
The return object is List<String>, where each String element contains the following content:
Return entity for deleted account prohibited words
19. Query Account Mute List
Description
通过账号下的禁言列表
接口地址(仅做说明使用):https://api.polyv.net/live/v3/user/chat/banned-user/list
Call Constraints
Unit Testing
@Test
public void testGetUserBannedList() throws IOException, NoSuchAlgorithmException {
LiveGetUserBannedListRequest liveGetUserBannedListRequest = new LiveGetUserBannedListRequest();
LiveGetUserBannedListResponse liveGetUserBannedListResponse;
try {
liveGetUserBannedListRequest.setCurrentPage(1);
liveGetUserBannedListRequest.setPageSize(10);
liveGetUserBannedListResponse = new LiveChatRoomServiceImpl().getUserBannedList(
liveGetUserBannedListRequest);
Assert.assertNotNull(liveGetUserBannedListResponse);
if (liveGetUserBannedListResponse != null) {
//to do something ......
log.debug("测试查询账号禁言列表成功 {}", JSON.toJSONString(liveGetUserBannedListResponse));
}
} 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
LiveGetUserBannedListResponseobject, 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 |
|---|---|---|---|
| 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 items per page [Corresponds to the size field in the API documentation] |
| appId | false | String | POLYV user APP_ID. This parameter is required for multi-account calls (i.e., when initMultiAccount() has been 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() has been 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
| Parameter Name | Type | Description |
|---|---|---|
| contents | Array | Mute data |
| pageSize | Integer | Number of data items displayed per page, default is 20 |
| 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] |
20. Mute/Unmute User
Description
通过登录聊天室的userId,禁言或者解禁用户
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/banned-user
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 testUpdateBannedUser() throws IOException, NoSuchAlgorithmException {
LiveUpdateBannedUserRequest liveUpdateBannedUserRequest = new LiveUpdateBannedUserRequest();
Boolean liveUpdateBannedUserResponse;
try {
String channelId = super.createChannel();
liveUpdateBannedUserRequest.setChannelId(channelId);
liveUpdateBannedUserRequest.setUserIds("ovtl9t_RxnrTdqkXqkT5Q5lnxp2A");
liveUpdateBannedUserResponse = new LiveChatRoomServiceImpl().updateBannedUser(liveUpdateBannedUserRequest);
Assert.assertNotNull(liveUpdateBannedUserResponse);
if (liveUpdateBannedUserResponse != null) {
//to do something ......
log.debug("测试禁言/解禁用户成功 {}", JSON.toJSONString(liveUpdateBannedUserResponse));
}
} 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 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, 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 |
| userIds | true | String | Chat room user IDs (not live streaming account IDs). Separate multiple users with commas ",". |
| toBanned | false | String | Y to mute, N to unmute |
| 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: 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: Official Website -> Login -> Live Streaming (Development Settings). |
Return Object Description
Mute/Unmute User Return Entity
21. Account Settings: Muting/Unmuting Users
Description
通过登录聊天室的userId,禁言或者解禁用户
接口地址(仅做说明使用):https://api.polyv.net/live/v3/user/chat/banned-user/update
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 testUpdateUserBannedViewer() throws IOException, NoSuchAlgorithmException {
LiveUpdateUserBannedViewerRequest liveUpdateUserBannedViewerRequest = new LiveUpdateUserBannedViewerRequest();
Boolean liveUpdateUserBannedViewerResponse;
try {
List<String> viewerIds = new ArrayList<>();
viewerIds.add("test");
liveUpdateUserBannedViewerRequest.setViewerIds(viewerIds);
liveUpdateUserBannedViewerRequest.setBanned("Y");
liveUpdateUserBannedViewerResponse = new LiveChatRoomServiceImpl().updateUserBannedViewer(
liveUpdateUserBannedViewerRequest);
Assert.assertNotNull(liveUpdateUserBannedViewerResponse);
if (liveUpdateUserBannedViewerResponse != null) {
//to do something ......
log.debug("测试账号设置禁言/解禁用户成功 {}", JSON.toJSONString(liveUpdateUserBannedViewerResponse));
}
} 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 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 |
|---|---|---|---|
| viewerIds | true | Array | Chat room user IDs (not live streaming account IDs), in JSON array format |
| banned | true | String | Y indicates muting, N indicates unmuting |
| appId | false | String | POLYV user APP_ID, 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: 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). Obtain it by registering on the Polyv official website: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
Account Settings: Mute/Unmute User Return Entity
22. Admin Sends Chat Message
Description
通过HTTP接口发送聊天文本内容,可指定发言者的头像、头衔、昵称,无需连接聊天室
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/send-admin-msg
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 testSendAdminMessage() throws IOException, NoSuchAlgorithmException {
LiveSendAdminMessageRequest liveSendAdminMessageRequest = new LiveSendAdminMessageRequest();
LiveSendAdminMessageResponse liveSendAdminMessageResponse;
try {
String channelId = super.createChannel();
liveSendAdminMessageRequest.setChannelId(channelId)
.setMsg("hello 大家好-通过API发过来的测试信息")
.setPic("https://5b0988e595225.cdn.sohucs.com/q_70,c_zoom," +
"w_640/images/20190129/e3b0d6311b1a411fa68125fc03b8ef67.jpeg")
.setNickName("thomas")
.setImgUrl("https://5b0988e595225.cdn.sohucs.com/q_70,c_zoom," +
"w_640/images/20190129/e3b0d6311b1a411fa68125fc03b8ef67.jpeg")
.setFreeReview(LiveConstant.Flag.YES.getFlag());
liveSendAdminMessageResponse = new LiveChatRoomServiceImpl().sendAdminMessage(liveSendAdminMessageRequest);
Assert.assertNotNull(liveSendAdminMessageResponse);
if (liveSendAdminMessageResponse != null) {
//to do something ......
log.debug("测试管理员发送聊天信息成功 {}", JSON.toJSONString(liveSendAdminMessageResponse));
}
} 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
LiveSendAdminMessageResponseobject 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 |
| msg | false | String | Text message to send. Either a text message or an image message must be provided, with a maximum length of 2000 characters. |
| imgUrl | false | String | URL of the image message to send. The URL does not support parameters. Either a text message or an image message must be provided. When sending an image message, the set nickname and avatar will not take effect. |
| pic | true | String | Admin avatar URL. The URL does not support parameters. |
| nickName | true | String | Nickname, with a maximum length of 8 characters. Excess characters will be truncated. |
| adminIndex | false | Integer | Admin index. Multiple admins can be specified to send messages. Default is a single admin. |
| actor | false | String | Title, with a maximum length of 4 characters. Excess characters will be truncated. If not provided, no title is displayed. |
| freeReview | false | String | Whether the message needs to go through review when the channel has review enabled. Default is N. Y: Not required, N: Required. |
| 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
| Parameter Name | Type | Description |
|---|---|---|
| msgId | String | Message ID for sending |
23. Update Chat Review Toggle
Description
更新聊天审核开关
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/update-censor-enabled
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 testUpdateChatCensorEnabled() throws IOException, NoSuchAlgorithmException {
LiveUpdateChatCensorRequest liveUpdateChatCensorRequest = new LiveUpdateChatCensorRequest();
Boolean liveUpdateChatCensorResponse;
try {
String channelId = super.createChannel();
liveUpdateChatCensorRequest.setChannelId(channelId);
liveUpdateChatCensorResponse = new LiveChatRoomServiceImpl().updateChatCensorEnabled(
liveUpdateChatCensorRequest);
Assert.assertNotNull(liveUpdateChatCensorResponse);
if (liveUpdateChatCensorResponse != null) {
//to do something ......
log.debug("测试更新聊天审核开关成功,当前状态 {}", liveUpdateChatCensorResponse);
}
} 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 Boolean object 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 | Required | Type | Description |
|---|---|---|---|
| channelId | true | String | Channel ID |
| enabled | false | String | Switch Y/N, */ |
| 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: 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: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
Upon successful setup, return the current chat review switch type: true if enabled, false if not enabled.
24. Sending Popup Messages on the Broadcasting End
Description
用于直播中,给开播讲师以弹窗形式发送特定消息的能力(当前仅支持给讲师触发)
接口地址(仅做说明使用):https://api.polyv.net/live/v4/chat/alert-to-special
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 testAlertChatSpecial() throws IOException, NoSuchAlgorithmException {
LiveAlertChatSpecialRequest liveAlertChatSpecialRequest = new LiveAlertChatSpecialRequest();
Boolean liveAlertChatSpecialResponse;
try {
String channelId = super.createChannel();
liveAlertChatSpecialRequest.setChannelId(channelId).setTitle("测试弹窗").setMessage("弹窗内容为hello world");
liveAlertChatSpecialResponse = new LiveChatRoomServiceImpl().alertChatSpecial(liveAlertChatSpecialRequest);
Assert.assertNotNull(liveAlertChatSpecialResponse);
if (liveAlertChatSpecialResponse != null) {
//to do something ......
log.debug("测试发送开播端弹窗消息成功 {}", liveAlertChatSpecialRequest);
}
} 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 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 fields [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 |
| title | true | String | Title Length must be >= 1 and <= 100 |
| message | true | String | Message description Length must be >= 1 and <= 500 |
| 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 invocation). 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 invocation). Obtain it by registering on the POLYV official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
true indicates a successful call, false indicates a failed call.
25. Publish Announcement
Description
发布频道公告,支持置顶和弹窗
接口地址(仅做说明使用):https://api.polyv.net/live/v4/chat/add-bullentin
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 testAddBullentin() throws IOException, NoSuchAlgorithmException {
LiveAddBullentinRequest liveAddBullentinRequest = new LiveAddBullentinRequest();
Boolean liveAddBullentinResponse;
try {
String channelId = super.createChannel();
liveAddBullentinRequest.setChannelId(channelId)
.setContent("测试发布公告")
.setIsTop(LiveConstant.Flag.YES.getFlag())
.setIsPop(LiveConstant.Flag.YES.getFlag());
liveAddBullentinResponse = new LiveChatRoomServiceImpl().addBullentin(liveAddBullentinRequest);
Assert.assertNotNull(liveAddBullentinResponse);
if (liveAddBullentinResponse != null) {
//to do something ......
log.debug("测试发布公告成功 {}", liveAddBullentinResponse);
}
} 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 |
| content | true | String | Announcement content |
| isTop | false | String | Whether to pin, values: Y/N, default N |
| isPop | false | String | Whether to pop up, values: Y/N, default N |
| appId | false | String | POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtain by registering on the POLYV official website: Official Website -> Login -> Live (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). Obtain by registering on the POLYV official website: Official Website -> Login -> Live (Development Settings) |
Return Object Description
true indicates a successful call, false indicates a failed call.
26. Query Channel Announcement List
Description
分页查询频道公告列表
接口地址(仅做说明使用):https://api.polyv.net/live/v4/chat/list-bullentin
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 Tests
@Test
public void testListBullentin() throws IOException, NoSuchAlgorithmException {
LiveListBullentinRequest liveListBullentinRequest = new LiveListBullentinRequest();
LiveListBullentinResponse liveListBullentinResponse;
try {
String channelId = super.createChannel();
liveListBullentinRequest.setChannelId(channelId)
.setPageNumber(1)
.setPageSize(10);
liveListBullentinResponse = new LiveChatRoomServiceImpl().listBullentin(liveListBullentinRequest);
Assert.assertNotNull(liveListBullentinResponse);
if (liveListBullentinResponse != null) {
//to do something ......
log.debug("测试查询公告列表成功 {}", JSON.toJSONString(liveListBullentinResponse));
}
} 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, return a
LiveListBullentinResponseobject, 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 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 Input Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| channelId | true | String | Channel ID |
| sort | false | String | Sorting field, createTime:asc for ascending order, createTime:desc for descending order |
| pageNumber | false | Integer | Page number for pagination, default is 1 |
| pageSize | false | Integer | Page size for pagination, default is 10, maximum is 1000 |
| 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 |
|---|---|---|
| pageSize | Integer | Number of items per page |
| currentPage | Integer | Current page [corresponds to the pageNumber field in the API documentation] |
| totalItems | Integer | Total number of items |
| totalPage | Integer | Total number of pages [corresponds to the totalPages field in the API documentation] |
| contents | Array | List of query results [see Bullentin Parameter Description] |
Bullentin Parameter Description
| Parameter | Type | Description |
|---|---|---|
| id | Long | Announcement ID |
| content | String | Announcement content |
| isTop | Integer | Whether to pin: 0-No, 1-Yes |
| isPop | Integer | Whether to pop up: 0-No, 1-Yes |
| canClose | Integer | Whether closable: 0-No, 1-Yes |
| createTime | Long | Creation time |
| nick | String | User nickname |
| pic | String | User avatar |
