Chat Room Service
1、批量导入频道严禁词
描述
批量导入频道严禁词
接口地址(仅做说明使用):https://api.polyv.net/live/v2/chat/%s/addBadWords
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回LiveBadWordResponse对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
false
String
频道号,不填则设置为通用设置内的严禁词
words
true
Array
严禁词列表
返回对象描述
count
Integer
请求参设设置了频道号,count则为该频道严禁词的数量,如果没有设置频道号,count为该该账户严禁词的数量
userId
String
POLYV用户ID,通过注册保利威官网获取,路径:官网->登录->直播(开发设置)
2、查询历史聊天信息
描述
查询一段时间内的聊天记录,时间格式为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
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回LiveGetMessageListResponse对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
startDay
true
Date
聊天记录的开始时间 格式为yyyy-MM-dd,例如:2021-03-01 或者格式为yyyy-MM-dd HH:mm:ss,例如:2021-03-01 16:30:12
endDay
true
Date
聊天记录的结束时间,要求同上
channelId
true
String
频道号
userType
false
String
用户类型,可以选择多个类型,用英文逗号隔开 slice:云课堂学员 teacher:讲师 guest:嘉宾 manager:管理员 assistant:助教 viewer:特邀观众 monitor:场监 attendee:研讨会参与者 student:普通直播观众
status
false
String
聊天记录审核状态,默认pass:已审核 pass:已审核 censor:审核中和删除
source
false
String
类型,不填默认公聊 extend:管理员私聊
roomId
false
String
如果有房间号,需要传入房间号,默认不传
hasTotal
false
String
是否返回当前查询总数,Y:是,N:否,默认为N 注:仅在查第一页有效,此参数可能会影响接口响应性能,若非强烈需求,建议不要传此参数,可以根据返回结果中的 contents 数组长度来判断是否还有下一页
currentPage
false
Integer
页数,默认为1【对应api文档的page字段】
pageSize
false
Integer
每页显示的数据条数,默认每页显示20条数据
返回对象描述
pageSize
Integer
每页显示的数据条数,默认每页显示20条数据
currentPage
Integer
当前页【对应api文档的pageNumber字段】
totalItems
Integer
记录总条数
totalPage
Integer
总页数【对应api文档的totalPages字段】
id
String
聊天消息id
accountId
String
账号id
clientIP
String
用户ip
content
String
聊天内容
event
String
事件,具体参考聊天室SDK
image
String
图片消息的图片地址
msgType
String
消息类型 redpaper:红包消息 get_redpaper:领取红包消息 chatImg:图片消息 custom:自定义消息(通过socket发送的自定义消息) reward:打赏消息 customerMessage:自定义消息(通过http接口发送的自定义消息) 为空:普通聊天消息
quote
String
引用
sessionId
String
场次号
roomId
String
房间号
channelId
String
频道号
time
Date
发送消息时的时间
userType
String
用户类型 slice:云课堂学员 teacher:讲师 guest:嘉宾 manager:管理员 assistant:助教 viewer:特邀观众 monitor:场监 attendee:研讨会参与者 student:普通直播观众
status
String
审核状态 pass:已审核 censor:审核中 delete:删除
sourceType
String
消息来源 public:群聊 extend:管理员私聊
actor
String
角色
banned
Boolean
是否禁言
channelId
String
频道号
clientIp
String
用户ip
nickname
String
观众昵称
pic
String
观众头像
roomId
String
房间号
sessionId
String
场次号
uid
String
socketId
userId
String
用户唯一标示
userSource
String
观众来源
userType
String
用户类型 slice:云课堂学员 teacher:讲师 guest:嘉宾 manager:管理员 assistant:助教 viewer:特邀观众 monitor:场监 attendee:研讨会参与者 student:普通直播观众
param4
String
用户自定义字段
param5
String
用户自定义字段
3、查询聊天室管理员信息
描述
查询聊天室管理员信息
接口地址(仅做说明使用):https://api.polyv.net/live/v2/channelSetting/%s/get-chat-admin
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回LiveGetChatAdminDataResponse对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
返回对象描述
nickname
String
讲师昵称
actor
String
讲师头衔
avatar
String
头像图片地址
4、查询频道禁言列表
描述
查询频道禁言列表
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/get-banned-list
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回String对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
type
true
String
查询禁言类型,ip : 聊天室用户的机器ip , userId : 聊天室用户的userId
toGetSubRooms
false
Integer
是否获取子房间的禁言列表,0:不获取,1:获取,默认为 0
返回对象描述
返回对象是List<String>,String具体元素内容如下: 返回当前频道的禁言列表
5、查询频道踢人列表
描述
查询频道踢人列表
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/list-kicked
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回LiveKickedListResponse对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
返回对象描述
返回对象是List<LiveKickedListResponse>,LiveKickedListResponse具体元素内容如下:
banned
Boolean
是否禁言
channelId
String
频道号
clientIp
String
C端观众ip
kickRefer
String
踢人方式,userId : 用户userId, ip : 用户登录IP
nickname
String
昵称【对应api文档的nick字段】
pic
String
头像图片地址
roomId
String
房间号
uid
String
聊天室socketid
userId
String
C端观众ID
userType
String
用户身份:管理员 manager,讲师 teacher, 助教 assistant, 嘉宾 guest,参与者 viewer,观看者 slice/student
6、查询频道严禁词/禁言IP列表
描述
接口用于获取频道的严禁词或者禁言IP列表
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/badword/list
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回String对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
type
false
String
查询类型: ip=禁言ip,badword=严禁词,默认为badword
返回对象描述
返回对象是List<String>,String具体元素内容如下: 获取当前频道的严禁词/禁言IP列表
7、查询账号严禁词列表
描述
接口用于获取账号下通用设置的严禁词列表
接口地址(仅做说明使用):https://api.polyv.net/live/v3/user/badword/list
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回String对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
此方法采用系统全局配置,不需要显式传递参数
返回对象描述
返回对象是List<String>,String具体元素内容如下: 当前保利威账号下通用设置的严禁词列表
8、查询咨询提问记录
描述
查询咨询提问记录
接口地址(仅做说明使用):https://api.polyv.net/live/v2/chat/%s/getQuestion
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回LiveGetConsultingRecordResponse对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
begin
false
Integer
起始下标,从0开始
end
false
Integer
结束下标,-1表示不分页
返回对象描述
返回对象是List<LiveGetConsultingRecordResponse>,LiveGetConsultingRecordResponse具体元素内容如下:
id
String
信息id
content
String
内容
time
Date
发言时间
event
String
消息类型,讲师回答:T_ANSWER,学生提问:S_QUESTION
userId
String
提问者ID【对应api文档的s_userId字段】
nick
String
观众昵称
pic
String
观众头像
userId
String
用户唯一标示
sessionId
String
场次号
channelId
String
频道号
banned
Boolean
是否禁言 true:禁言 false:不禁言
userType
String
用户类型,目前有teacher(老师)、assistant(助教)、manager(管理员)、slice(云课堂学员)
9、设置讲师信息
描述
设置讲师信息
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/account/updateTeacher
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回Boolean对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
nickname
false
String
讲师昵称
actor
false
String
讲师头衔
passwd
false
String
频道密码,长度<=16,必须同时包含字母和数字
avatar
false
String
头像图片地址,如果为空,则使用默认头像
返回对象描述
true 设置讲师信息成功,false 设置讲师信息失败
10、设置聊天室禁言ip
描述
设置聊天室禁言ip
接口地址(仅做说明使用):https://api.polyv.net/live/v2/chat/%s/addBannedIP
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回String对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
ip
true
String
禁言IP,如 234.22.3.34
返回对象描述
返回对象是List<String>,String具体元素内容如下: 当前所有的禁言ip列表
11、设置聊天室管理员信息
描述
设置聊天室管理员信息
接口地址(仅做说明使用):https://api.polyv.net/live/v2/channelSetting/%s/set-chat-admin
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回Boolean对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
nickname
true
String
管理员昵称,长度不能超过8个字符
actor
true
String
管理员头衔,长度不能超过4个字符
avatar
true
File
管理员头像,支持jpg、jpeg、png三种格式,大小不能超过2Mb
返回对象描述
true 设置成功,false 设置失败
12、删除禁言IP/严禁词
描述
删除禁言IP/严禁词
接口地址(仅做说明使用):https://api.polyv.net/live/v2/chat/%s/delBanned
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回Boolean对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
type
true
String
传输内容类型 ip:属性content内容为IP badword 属性content内容为严禁词
content
true
String
要取消的ip或者严禁词,支持传入多个ip或者严禁词,通过","区分
返回对象描述
true 删除成功 ,false 删除失败
13、删除单条聊天记录
描述
根据聊天的id删除对应聊天记录
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/send-admin-msg
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回Boolean对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
id
true
String
聊天记录对应的id
返回对象描述
true 删除成功, false 删除失败
14、删除频道聊天记录
描述
删除频道聊天记录
接口地址(仅做说明使用):https://api.polyv.net/live/v2/chat/%s/cleanChat
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回Boolean对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
返回对象描述
true 删除成功, false 删除失败
15、管理员发送频道聊天信息
描述
管理员发送频道聊天信息
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/send
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回Boolean对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
content
true
String
聊天信息内容
role
true
String
发送人角色(目前为只提供管理员角色,值为'ADMIN')
返回对象描述
true 发送成功, false 发送失败
16、发送自定义聊天信息
描述
聊天室发送系统消息
接口地址(仅做说明使用):https://api.polyv.net/live/v1/channelSetting/%s/send-chat
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回Boolean对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
content
false
String
需要发送的文字(直接设值即可,禁止进行base64编码),content、imgUrl不能同时为空,可以同时提交
imgUrl
false
String
需要发送的图片,content、imgUrl不能同时为空,可以同时提交
返回对象描述
true 发送成功, false 发送失败
17、发送自定义消息
描述
发送聊天室自定义消息
接口地址(仅做说明使用):https://api.polyv.net/live/v4/chat/send-custom-message
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
2、需要发送的文字内容(content)或者图片(imgUrl)不能同时为空,可以同时提交
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回Boolean对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
content
false
String
发送文字内容
imgUrl
false
String
发送的图片url地址
joinHistoryList
false
Integer
是否加入聊天历史数据,默认为1 1:加入到聊天历史数据 0:不加入
watchType
false
Integer
此消息面向何种角色发送(默认为1,支持多选,如:45) 1:面向频道所有角色 2:仅面向频道内观众角色 3:仅面向特殊角色(讲师、嘉宾、助教、管理员) 4:讲师 5:嘉宾 6:助教 7:管理员
返回对象描述
发送自定义消息返回实体
18、查询频道虚拟人数设置
描述
查询频道的虚拟人数设置
接口地址(仅做说明使用):https://api.polyv.net/live/v4/channel/robot/setting/get
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@Test
public void testGetRobotSetting() throws IOException, NoSuchAlgorithmException {
LiveGetRobotSettingRequest liveGetRobotSettingRequest = new LiveGetRobotSettingRequest();
LiveGetRobotSettingResponse liveGetRobotSettingResponse;
try {
String channelId = super.createChannel();
liveGetRobotSettingRequest.setChannelId(channelId);
liveGetRobotSettingResponse = new LiveChatRoomServiceImpl().getRobotSetting(liveGetRobotSettingRequest);
Assert.assertNotNull(liveGetRobotSettingResponse);
if (liveGetRobotSettingResponse != null) {
//to do something ......
log.debug("测试查询频道虚拟人数设置成功 {}", JSON.toJSONString(liveGetRobotSettingResponse));
}
} 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;
}
}
单元测试说明
1、请求正确,返回LiveGetRobotSettingResponse对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
返回对象描述
channelId
String
频道号
robotNumber
Integer
聊天室显示虚拟人数
addRobotModel
String
人数显示模式 timely:立即生效 fixed_time:分时生效
virtualBookingNumber
Integer
虚拟预约人数
changeTime
Integer
生效时间,单位毫秒
leftTime
Long
距离下次可设置时间,单位毫秒
19、查询频道虚拟人数详情
描述
查询虚拟人数统计情况
接口地址(仅做说明使用):https://api.polyv.net/live/v4/channel/robot/stats/get
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@Test
public void testGetRobotStats() throws IOException, NoSuchAlgorithmException {
LiveGetRobotStatsRequest liveGetRobotStatsRequest = new LiveGetRobotStatsRequest();
LiveGetRobotStatsResponse liveGetRobotStatsResponse;
try {
String channelId = super.createChannel();
liveGetRobotStatsRequest.setChannelId(channelId);
liveGetRobotStatsResponse = new LiveChatRoomServiceImpl().getRobotStats(liveGetRobotStatsRequest);
Assert.assertNotNull(liveGetRobotStatsResponse);
if (liveGetRobotStatsResponse != null) {
//to do something ......
log.debug("测试查询频道虚拟人数详情成功 {}", JSON.toJSONString(liveGetRobotStatsResponse));
}
} 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;
}
}
单元测试说明
1、请求正确,返回LiveGetRobotStatsResponse对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
返回对象描述
realViewerCount
Integer
真实人数
robotCount
Integer
虚拟人数
displayCount
Integer
显示人数
realSubscribeCount
Integer
真实预约人数
pv
Long
观看次数
20、设置频道虚拟人数
描述
设置频道虚拟人数
接口地址(仅做说明使用):https://api.polyv.net/live/v4/channel/robot/setting/update
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@Test
public void testUpdateRobotSetting() throws IOException, NoSuchAlgorithmException {
LiveUpdateRobotSettingRequest liveUpdateRobotSettingRequest = new LiveUpdateRobotSettingRequest();
Boolean liveUpdateRobotSettingResponse;
try {
String channelId = super.createChannel();
liveUpdateRobotSettingRequest.setChannelId(channelId)
.setAddRobotModel(LiveConstant.RobotModel.FIXED_TIME.getValue())
.setChangeTime(20)
.setRobotNumber(500)
.setVirtualBookingNumber(200);
liveUpdateRobotSettingResponse = new LiveChatRoomServiceImpl().updateRobotSetting(
liveUpdateRobotSettingRequest);
Assert.assertTrue(liveUpdateRobotSettingResponse);
if (liveUpdateRobotSettingResponse) {
//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;
}
}
单元测试说明
1、请求正确,返回Boolean对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
robotNumber
true
Integer
聊天室显示虚拟人数
addRobotModel
true
String
人数显示模式 timely:立即生效 fixed_time:分时生效
changeTime
false
Integer
生效时间,addRobotModel为fixed_time分时生效时必填,单位秒,最小值为20(20秒),最大值为18000(300分钟)
virtualBookingNumber
false
Integer
虚拟预约人数
返回对象描述
设置频道虚拟人数返回实体
21、停止频道虚拟人数
描述
设置虚拟人数分时生效后停止虚拟人数增加
接口地址(仅做说明使用):https://api.polyv.net/live/v4/channel/robot/pause
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@Test
public void testPauseRobot() throws IOException, NoSuchAlgorithmException {
LivePauseRobotRequest livePauseRobotRequest = new LivePauseRobotRequest();
Boolean livePauseRobotResponse;
try {
String channelId = super.createChannel();
livePauseRobotRequest.setChannelId(channelId);
livePauseRobotResponse = new LiveChatRoomServiceImpl().pauseRobot(livePauseRobotRequest);
Assert.assertTrue(livePauseRobotResponse);
if (livePauseRobotResponse) {
//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;
}
}
单元测试说明
1、请求正确,返回Boolean对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
返回对象描述
停止频道虚拟人数返回实体
22、删除账号严禁词
描述
删除账号通用设置的严禁词,支持批量删除多个严禁词
接口地址(仅做说明使用):https://api.polyv.net/live/v3/user/badword/delete
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回String对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
words
true
String
要删除的严禁词,多个以英文逗号分隔,例如:账号严禁词1,账号严禁词2
返回对象描述
返回对象是List<String>,String具体元素内容如下: 删除账号严禁词返回实体
23、查询账号禁言列表
描述
通过账号下的禁言列表
接口地址(仅做说明使用):https://api.polyv.net/live/v3/user/chat/banned-user/list
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回LiveGetUserBannedListResponse对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
currentPage
false
Integer
页数,默认为1【对应api文档的page字段】
pageSize
false
Integer
每页显示的数据条数,默认每页显示20条数据【对应api文档的size字段】
返回对象描述
contents
Array
禁言数据
pageSize
Integer
每页显示的数据条数,默认每页显示20条数据
currentPage
Integer
当前页【对应api文档的pageNumber字段】
totalItems
Integer
记录总条数
totalPage
Integer
总页数【对应api文档的totalPages字段】
24、禁言/解禁用户
描述
通过登录聊天室的userId,禁言或者解禁用户
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/banned-user
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回Boolean对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
userIds
true
String
聊天室用户ID(非直播账号ID),多个用户用半角逗号","隔开。
toBanned
false
String
Y表示禁言,N表示解除禁言
返回对象描述
禁言/解禁用户返回实体
25、账号设置禁言/解禁用户
描述
通过登录聊天室的userId,禁言或者解禁用户
接口地址(仅做说明使用):https://api.polyv.net/live/v3/user/chat/banned-user/update
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回Boolean对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
viewerIds
true
Array
聊天室用户ID(非直播账号ID),json数组格式
banned
true
String
Y表示禁言,N表示解除禁言
返回对象描述
账号设置禁言/解禁用户返回实体
26、管理员发送聊天信息
描述
通过HTTP接口发送聊天文本内容,可指定发言者的头像、头衔、昵称,无需连接聊天室
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/send-admin-msg
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回LiveSendAdminMessageResponse对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
msg
false
String
发送的文本消息,文本消息和图片消息必传一个,最长为2000字符
imgUrl
false
String
发送的图片消息地址,url不支持带参数。文本消息和图片消息必传一个 发送图片消息时,设置的昵称和头像暂不生效
pic
true
String
管理员头像,url不支持带参数。
nickName
true
String
昵称,最大为8个长度,超出会被截断
adminIndex
false
Integer
管理员索引,可以指定多个管理员发送消息,默认只有一个管理员
actor
false
String
头衔,最大为4个长度,超出会被截断,不传参数则表示无头衔
freeReview
false
String
当频道开启审核后消息是否需要经过审核,默认为N Y:不需要 N:需要
返回对象描述
msgId
String
发送消息ID
27、更新聊天审核开关
描述
更新聊天审核开关
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/chat/update-censor-enabled
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回Boolean对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
enabled
false
String
开关 Y/N, */
返回对象描述
设置成功返回当前聊天审核开关类型,开启为true,没开启为false
28、发送开播端弹窗消息
描述
用于直播中,给开播讲师以弹窗形式发送特定消息的能力(当前仅支持给讲师触发)
接口地址(仅做说明使用):https://api.polyv.net/live/v4/chat/alert-to-special
调用约束
1、接口调用有频率限制,详细请查看,调用常见异常,详细请查看
单元测试
@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;
}
}
单元测试说明
1、请求正确,返回Boolean对象,B端依据此对象处理业务逻辑;
2、请求参数校验不合格,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 输入参数 [xxx.chat.LivexxxRequest]对象校验失败,失败字段 [pic不能为空 / msg不能为空] ]
3、服务器处理异常,抛出PloyvSdkException,错误信息见PloyvSdkException.getMessage(),如 [ 保利威请求返回数据错误,请求流水号:66e7ad29fd04425a84c2b2b562d2025b,错误原因: invalid signature. ]
请求入参描述
channelId
true
String
频道号
title
true
String
标题 长度大于等于1,长度小于等于100
message
true
String
消息说明 长度大于等于1,长度小于等于500
返回对象描述
true为调用成功,false为调用失败
Last updated
Was this helpful?