1、发送审核通过的聊天消息
2、(channelId, timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
http://api.polyv.net/live/v4/chat/message/audit
http://api.polyv.net/live/v4/chat/message/audit?appId=fxlwyesvqd&sign=942AC99EACD1D11FF35E480414403EB0×tamp=1680162971000&channelId=3808479
[
{
"msgId":"msg-1",
"content":"我发送了一条消息",
"viewerId":"sadboy",
"nickName":"polyv"
}
]
强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
private static final Logger log = LoggerFactory.getLogger(getClass());
/**
* 审核通过聊天信息
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void messageAuditTest() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v4/chat/message/audit";
String channelId = "1965681";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("channelId", channelId);
requestMap.put("timestamp", timestamp);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
url = HttpUtil.appendUrl(url, requestMap);
Map<String, String> jsonMap = new HashMap<>();
jsonMap.put("msgId","msg-1");
jsonMap.put("content","我发送了一条消息");
jsonMap.put("viewerId","sadboy");
jsonMap.put("nickName","polyv");
List<Map<String, String>> list = new ArrayList<>();
list.add(jsonMap);
String response = HttpUtil.postJsonBody(url,JSON.toJSONString(list),null);
log.info("测试审核通过聊天信息成功:{}", response);
//do somethings
}
{
"code": 200,
"status": "success",
"requestId": "807edf69deb540cd8b1f7a8b0e2dc883.64.16801629319610385",
"data": [
{
"msgId": "123",
"id": "3ec969a0-ced0-11ed-87bd-6de896f75816",
"status": true,
"msg": "发送成功"
}
],
"success": true
}
{
"code": 400,
"status": "error",
"requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}