1、批量创建直播频道
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
http://api.polyv.net/live/v3/channel/basic/batch-create
http://api.polyv.net/live/v3/channel/basic/batch-create?appId=frlr1zazn3&sign=1B76E8026C5F03B92E4725D6835DA57E×tamp=1636707112481
{
"channels": [
{
"name": "测试批量创建频道2(子账号)",
"channelPasswd": "Hi826g",
"subAccount": "test-dev@qq.com",
"categoryId": 391352
},
{
"name": "测试批量创建频道2(主账号)",
"channelPasswd": "Hi826g",
"autoPlay": 0,
"playerColor": "#454545",
"scene": "ppt",
"categoryId": 391352
}
]
}
强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
private static final Logger log = LoggerFactory.getLogger(ChannelOperateTest.class);
/**
* 批量创建频道
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testBatchCreateChannels() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际
String appId = super.appId;
String appSecret = super.appSecret;
String userId = super.userId;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v3/channel/basic/batch-create";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
url = HttpUtil.appendUrl(url, requestMap);
String password = getRandomString(6);
String json = "{\"channels\":[{\"name\":\"测试批量创建频道2(子账号)\",\"channelPasswd\":\"%s\"," +
"\"subAccount\":\"test-dev@qq.com\",\"categoryId\":391352},{\"name\":\"测试批量创建频道2(主账号)\"," +
"\"channelPasswd\":\"%s\",\"autoPlay\":0,\"playerColor\":\"#454545\",\"scene\":\"ppt\"," +
"\"categoryId\":391352}]}";
json = String.format(json, password, password);
String response = HttpUtil.postJsonBody(url, json, null);
log.info("测试批量创建频道,返回值:{}", response);
//do somethings
}
{
"code": 200,
"status": "success",
"message": "",
"data": {
"channels": [
{
"channelId": 2671471,
"userId": "1b448be323",
"name": "测试批量创建频道2(子账号)",
"publisher": "主持人",
"description": "",
"url": "rtmp://push-d1.videocc.net/recordf/1b448be3231636707115007c115?auth_key=1636708917-0-0-355f0b98f5f93ddc588fcd7770fe07fa",
"stream": "1b448be3231636707115007c115",
"logoImage": "https://liveimages.videocc.net/uploaded/images/2021/04/fy3ce1e8uh.png",
"logoOpacity": 0.37,
"logoPosition": "tr",
"logoHref": "",
"coverImage": "",
"coverHref": "",
"waitImage": "",
"waitHref": "",
"cutoffImage": "",
"cutoffHref": "",
"advertType": "NONE",
"advertDuration": 0,
"advertWidth": 0,
"advertHeight": 0,
"advertImage": "",
"advertHref": "",
"advertFlvVid": "",
"advertFlvUrl": "",
"playerColor": "#666666",
"autoPlay": false,
"warmUpFlv": "",
"passwdRestrict": false,
"passwdEncrypted": "",
"isOnlyAudio": "N",
"isLowLatency": "N",
"m3u8Url": "http://pull-d1.videocc.net/recordf/1b448be3231636707115007c115.m3u8?auth_key=1636707117-0-0-3dc1259df0643a2dc9c61c40b9d17c44",
"m3u8Url1": "",
"m3u8Url2": "",
"m3u8Url3": "",
"channelLogoImage": "https://liveimages.videocc.net/assets/wimages/pc_images/logo.png",
"scene": "alone",
"channelViewerPasswd": null,
"channelPasswd": "Hi826g",
"linkMicLimit": 16,
"streamType": "client",
"pureRtcEnabled": "N",
"type": "normal",
"cnAndEnLiveEnabled": "N",
"pushEnUrl": null,
"closeDanmu": "N",
"currentTimeMillis": 1636707119516
},
{
"channelId": 2671472,
"userId": "1b448be323",
"name": "测试批量创建频道2(主账号)",
"publisher": "主持人",
"description": "",
"url": "rtmp://push-d1.videocc.net/recordf/1b448be32316367071173751967?auth_key=1636708919-0-0-2b2602020d19528b19d6374b12fe9263",
"stream": "1b448be32316367071173751967",
"logoImage": "https://liveimages.videocc.net/uploaded/images/2021/04/fy3ce1e8uh.png",
"logoOpacity": 0.37,
"logoPosition": "tr",
"logoHref": "",
"coverImage": "",
"coverHref": "",
"waitImage": "",
"waitHref": "",
"cutoffImage": "",
"cutoffHref": "",
"advertType": "NONE",
"advertDuration": 0,
"advertWidth": 0,
"advertHeight": 0,
"advertImage": "",
"advertHref": "",
"advertFlvVid": "",
"advertFlvUrl": "",
"playerColor": "#666666",
"autoPlay": false,
"warmUpFlv": "",
"passwdRestrict": false,
"passwdEncrypted": "",
"isOnlyAudio": "N",
"isLowLatency": "N",
"m3u8Url": "http://pull-d1.videocc.net/recordf/1b448be32316367071173751967.m3u8?auth_key=1636707119-0-0-19617586a7f61654216cce2c4827cebc",
"m3u8Url1": "",
"m3u8Url2": "",
"m3u8Url3": "",
"channelLogoImage": "https://liveimages.videocc.net/assets/wimages/pc_images/logo.png",
"scene": "ppt",
"channelViewerPasswd": null,
"channelPasswd": "Hi826g",
"linkMicLimit": 16,
"streamType": "client",
"pureRtcEnabled": "N",
"type": "normal",
"cnAndEnLiveEnabled": "N",
"pushEnUrl": null,
"closeDanmu": "N",
"currentTimeMillis": 1636707119516
}
]
}
}
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}