1、设置礼物打赏-现金支付礼物(旧版后台为:道具打赏)
2、(channelId, timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
http://api.polyv.net/live/v3/channel/donate/update-good
http://api.polyv.net/live/v3/channel/donate/update-good?appId=frlr1zazn3&sign=3ADDD49DB62A77BFDC0CA62585A24011&channelId=2149710×tamp=1621844081667
{
"enabled": "Y",
"goods": [{
"goodName": "鲜花333",
"goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/01-flower.png",
"goodPrice": 0,
"goodEnabled": "Y"
}, {
"goodName": "咖啡",
"goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/02-coffee.png",
"goodPrice": 0.99,
"goodEnabled": "Y"
}, {
"goodName": "点赞",
"goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/03-good.png",
"goodPrice": 1.99,
"goodEnabled": "Y"
}, {
"goodName": "掌声",
"goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/04-applaud.png",
"goodPrice": 2.99,
"goodEnabled": "Y"
}, {
"goodName": "666",
"goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/05-666.png",
"goodPrice": 6.66,
"goodEnabled": "Y"
}, {
"goodName": "小星星",
"goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/06-star.png",
"goodPrice": 9.99,
"goodEnabled": "Y"
}, {
"goodName": "钻石",
"goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/07-diamond.png",
"goodPrice": 19.99,
"goodEnabled": "Y"
}, {
"goodName": "跑车",
"goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/08-car.png",
"goodPrice": 29.99,
"goodEnabled": "Y"
}, {
"goodName": "火箭233",
"goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/09-rocket.png",
"goodPrice": 66.66,
"goodEnabled": "Y"
}]
}
强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
private static final Logger log = LoggerFactory.getLogger(PageInteractionTest.class);
/**
* 设置道具打赏
* @throws IOException
*/
@Test
public void testUpdateGood() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId=super.appId;
String appSecret=super.appSecret;
String userId = super.userId;
String timestamp=String.valueOf(System.currentTimeMillis());
//业务参数
String channelId = "2149710";
//http 调用逻辑
Map<String,String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp",timestamp);
requestMap.put("channelId",channelId);
requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
String url = "http://api.polyv.net/live/v3/channel/donate/update-good";
//拼接url
url = HttpUtil.appendUrl(url, requestMap);
String body = "{\"enabled\": \"Y\",\"goods\":[{\"goodName\":\"鲜花333\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/01-flower.png\",\"goodPrice\":0,\"goodEnabled\":\"Y\"},{\"goodName\":\"咖啡\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/02-coffee.png\",\"goodPrice\":0.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"点赞\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/03-good.png\",\"goodPrice\":1.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"掌声\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/04-applaud.png\",\"goodPrice\":2.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"666\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/05-666.png\",\"goodPrice\":6.66,\"goodEnabled\":\"Y\"},{\"goodName\":\"小星星\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/06-star.png\",\"goodPrice\":9.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"钻石\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/07-diamond.png\",\"goodPrice\":19.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"跑车\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/08-car.png\",\"goodPrice\":29.99,\"goodEnabled\":\"Y\"},{\"goodName\":\"火箭233\",\"goodImg\":\"//livestatic.videocc.net/uploaded/images/webapp/channel/donate/09-rocket.png\",\"goodPrice\":66.66,\"goodEnabled\":\"Y\"}]}";
String response = HttpUtil.postJsonBody(url,body,null);
log.info("测试设置道具打赏接口返回值:{}",response);
//do somethings
}
{
"code": 200,
"status": "success",
"message": "",
"data": true
}
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}