Batch Create Channels for Receiving Relay
Updated: 2023-04-04 09:31:23
API Description
1、根据发起转播的频道,批量创建接收转播的频道
2、(channelId, timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
API URL
http://api.polyv.net/live/v3/channel/transmit/batch-create
Request Method
POST
API Constraints
The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
Supports creating up to 100 receiving relay channels at once. The initiating relay channel supports up to 500 receiving relay channels.
Request Parameters Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See details for obtaining secret key |
| timestamp | true | Long | Current 13-digit millisecond timestamp, valid for 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must not be saved or used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See signature generation rules |
| channelId | true | String | Channel ID (the initiating relay channel ID) |
Request Body Parameters Description
| Type | Required | Description |
|---|---|---|
| Array |
true | List of channel names for receiving relay, e.g., ["Polyv Receive Relay Test Channel"] |
Example
http://api.polyv.net/live/v3/channel/transmit/batch-create?appId=frlr1zazn3&sign=D02FA683640135D843D485EE84F6632A&channelId=2588188×tamp=1632809855078
Request body JSON parameters:
[
"接收转播频道1",
"接收转播频道2"
]
Response Parameters Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code, 200 for success, non-200 for failure See global error description |
| status | String | Response status text |
| message | String | Response description, assists in describing error reasons when code is 400 or 500 |
| data | Array | List of successfully created receiving relay channel information See ChannelInfo field description |
ChannelInfo Parameters Description
| Parameter | Type | Description |
|---|---|---|
| channelId | Integer | Channel ID |
| name | String | Channel name |
| channelPasswd | String | Channel password |
| authType | String | Channel viewing conditions |
| playBackEnabled | String | Whether playback is enabled, Y: enabled, N: disabled |
| streamType | String | Channel push stream method |
| debugEnabled | String | Whether debugging is enabled, Y: enabled, N: disabled |
| stream | String | Channel stream name |
| status | String | Channel status |
| categoryId | Integer | Channel category ID |
| categoryName | String | Channel category name |
| isSmallClass | String | Whether the channel is a small class, Y: enabled, N: disabled |
| newScene | String | Channel live streaming scene, consistent with the initiating relay channel |
| template | String | Channel live streaming template, consistent with the initiating relay channel |
| createdTime | Long | Channel creation time |
| coverImage | String | Channel cover image |
| type | String | Channel type, transmit: initiating relay, normal: regular channel, receive: receiving relay |
| startTime | Long | Channel start time |
| publisher | String | Channel host |
| splashImg | String | Channel splash image URL |
| splashEnabled | String | Channel splash image toggle, Y: enabled, N: disabled |
| pureRtcEnabled | String | Channel low-latency live streaming toggle, Y: enabled, N: disabled |
| roomIds | String | Channel sub-room information, returns null if none |
Java Request Example
For quick integration of basic code, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source code project. HttpUtil.java and LiveSignUtil.java in the test cases are included in the downloaded file.
@Test
public void testBatchCreateTransmitChannel() 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/transmit/batch-create";
String channelId = "2588188";
//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));
url = HttpUtil.appendUrl(url,requestMap);
List<String> list = new ArrayList<>();
list.add("接收转播频道1");
list.add("接收转播频道2");
String json= JSON.toJSONString(list);
String response = HttpUtil.postJsonBody(url, json,null);
log.info("测试修改频道信息,返回值:{}", response);
}
Response Example
Success Example
{
"code": 200,
"status": "success",
"message": "",
"data": [
{
"channelId": 2588440,
"name": "接收转播频道1",
"channelPasswd": "8pWtmd",
"authType": "phone",
"streamType": "client",
"debugEnabled": "N",
"playBackEnabled": "N",
"stream": "1b448be3231632809860172afac",
"status": "客户端推流/直播结束",
"categoryId": 340019,
"categoryName": "默认分类",
"isSmallClass": "N",
"scene": "ppt",
"newScene": null,
"template": null,
"createdTime": 1632809860000,
"appId": null,
"coverImage": "",
"type": "receive",
"startTime": null,
"publisher": "主持人",
"channelLogo": null,
"splashImg": "//liveimages.videocc.net/uploaded/images/2021/09/g2bta2pjbw.jpg",
"splashEnabled": "Y",
"pureRtcEnabled": "N",
"watchTimes": null,
"roomIds": null,
"transmitType": null,
"rtcType": null,
"channelSessionId": null,
"lastPushStreamTime": null
},
{
"channelId": 2588441,
"name": "接收转播频道2",
"channelPasswd": "8pWtmd",
"authType": "phone",
"streamType": "client",
"debugEnabled": "N",
"playBackEnabled": "N",
"stream": "1b448be323163280986017418fb",
"status": "客户端推流/直播结束",
"categoryId": 340019,
"categoryName": "默认分类",
"isSmallClass": "N",
"scene": "ppt",
"newScene": null,
"template": null,
"createdTime": 1632809860000,
"appId": null,
"coverImage": "",
"type": "receive",
"startTime": null,
"publisher": "主持人",
"channelLogo": null,
"splashImg": "//liveimages.videocc.net/uploaded/images/2021/09/g2bta2pjbw.jpg",
"splashEnabled": "Y",
"pureRtcEnabled": "N",
"watchTimes": null,
"roomIds": null,
"transmitType": null,
"rtcType": null,
"channelSessionId": null,
"lastPushStreamTime": null
}
]
}
Error Example
{
"code": 400,
"status": "error",
"message": "application not found.",
"data": ""
}
