1、发送打赏消息
2、请求成功后,服务器会向聊天室的用户广播打赏消息,详见直播聊天室API接口
3、接口支持https协议
http://api.polyv.net/live/v3/channel/chat/send-reward-msg
http://api.polyv.net/live/v3/channel/chat/send-reward-msg
viewerId=1615772956066&goodImage=https%3A%2F%2Fs1.videocc.net%2Fdefault-img%2Fdonate%2Fflower.png&appId=frlr1zazn3&nickname=rock&sign=EB6BB879F2C5962E77324C81A9C453D0&donateType=good&avatar=https%3A%2F%2Flivestatic.videocc.net%2Fuploaded%2Fimages%2Fwebapp%2Favatar%2Fdefault-teacher.png&channelId=2191532&content=%E9%B2%9C%E8%8A%B1×tamp=1621844118743
强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
private static final Logger log = LoggerFactory.getLogger(LiveInteractionTest.class);
/**
* 发送打赏消息
* @throws IOException
*/
@Test
public void testSendRewardMsg() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId=super.appId;
String appSecret=super.appSecret;
String userId = super.userId;
String timestamp=String.valueOf(System.currentTimeMillis());
//业务参数
String channelId = "2191532";
String nickname = "rock";
String avatar = "https://livestatic.videocc.net/uploaded/images/webapp/avatar/default-teacher.png";
String viewerId = "1615772956066";
String donateType = "good";
String content = "鲜花";
String goodImage = "http://s1.videocc.net/default-img/donate/flower.png";
String url = "http://api.polyv.net/live/v3/channel/chat/send-reward-msg";
//http 调用逻辑
Map<String,String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp",timestamp);
requestMap.put("channelId",channelId);
requestMap.put("viewerId",viewerId);
requestMap.put("nickname",nickname);
requestMap.put("avatar",avatar);
requestMap.put("donateType",donateType);
requestMap.put("content",content);
requestMap.put("goodImage",goodImage);
requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.postFormBody(url,requestMap);
log.info("测试发送打赏消息接口返回值:{}",response);
//do somethings
}
{
"code": 200,
"status": "success",
"message": "",
"data": ""
}
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}