1、创建MR频道
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
http://api.polyv.net/live/v4/channel/mr/create
http://api.polyv.net/live/v4/channel/mr/create?appId=frlr1zazn3&sign=ECFC0A76E357F3EF2D1110BEB92C1045×tamp=1659063884736
{
"name": "MR直播测试频道",
"startTime": "1779254040000",
"splashImg": "https://liveimages.videocc.net/uploaded/images/2021/09/g2bta2pjbw.jpg"
}
强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
private static final Logger log = LoggerFactory.getLogger(ChannelOperateTest.class);
/**
* 创建MR频道
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testCreateMrChannel() 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/channel/mr/create";
String name = "MR直播接口测试";
String categoryId = "391352";
Long startTime = new Date().getTime() + 30 * 60 * 1000l;
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
Map<String, String> bodyMap = new HashMap<>();
bodyMap.put("name", name);
bodyMap.put("categoryId", categoryId);
bodyMap.put("startTime", String.valueOf(startTime));
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
String body = JSON.toJSONString(bodyMap);
url = HttpUtil.appendUrl(url, requestMap);
String response = HttpUtil.postJsonBody(url, body, null);
log.info("测试创建MR频道成功:{}", response);
//do somethings
}
{
"code": 200,
"status": "success",
"requestId": "ddf972812a804e0ba9122fd721274592.69.16590638894645319",
"data": {
"channelId": ******,
"name": "MR直播接口测试",
"userId": "1b448be323",
"channelPasswd": "9cNkSc",
"assistantAccount": "0013265559",
"assistantPasswd": "38kYPY"
},
"success": true
}
{
"code": 400,
"status": "error",
"requestId": "4081dbac03e6441e8bdd301d8feee5a2.124.16360831818611581",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}