Create MR Channel
Updated: 2023-12-04 17:25:11
API Description
1、创建MR频道
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
API URL
http://api.polyv.net/live/v4/channel/mr/create
Request Method
POST
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls are subject to rate limits. See details
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See Get 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 never be stored or used directly on the client. All APIs must be called through your own server to relay requests to the POLYV server for response data. See Signature Generation Rules |
Request Body Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| name | true | String | Live stream name, max length 100 |
| categoryId | false | Integer | Category ID |
| startTime | false | Long | Start time, 13-digit millisecond timestamp [Note: Only used for countdown display before the live stream, does not affect the instructor's start operation] |
| channelPasswd | false | String | MR console password, length 6-16, must contain both letters and numbers. If not provided, the system will generate one randomly |
| assistantPasswd | false | String | MR live assistant role password, length 6-16, must contain both letters and numbers. If not provided, the system will generate one randomly |
| splashImg | false | String | Splash page image URL. For images not under a Polyv domain, first call Upload All Channel Decoration Image Materials to upload |
| subAccount | false | String | Sub-account email. Once submitted, the channel account's backend permissions will follow the sub-account's channel permissions |
Example
http://api.polyv.net/live/v4/channel/mr/create?appId=frlr1zazn3&sign=ECFC0A76E357F3EF2D1110BEB92C1045×tamp=1659063884736
Request body JSON parameters:
{
"name": "MR直播测试频道",
"startTime": "1779254040000",
"splashImg": "https://liveimages.videocc.net/uploaded/images/2021/09/g2bta2pjbw.jpg"
}
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Status code, same as HTTP status code, used to determine the basic response status |
| status | String | Response result, determined by the business. Returns success on success, error on failure |
| success | Boolean | Whether the response was successful |
| requestId | String | Request ID, a unique UUID generated for each request. Only for troubleshooting and debugging, should not be tied to business logic |
| error | Object | Error information when status code is not 200 See Error Field Description |
| data | Object | See data field description |
Error Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Error code, used to identify the specific error reason |
| desc | String | Error description, corresponding to error.code |
data Parameter Description
| Parameter | Type | Description |
|---|---|---|
| channelId | String | Channel ID |
| name | String | Channel name |
| userId | String | Live account userId |
| channelPasswd | String | MR live - console login password |
| assistantAccount | String | MR live - live assistant account |
| assistantPasswd | String | MR live - live assistant login password |
Java Request Example
For quick integration of basic code, please download the relevant dependency source code. Click to download source code. After downloading, add it to your own source project. The test cases HttpUtil.java and LiveSignUtil.java are included in the download file.
It is strongly recommended to use the Live Java SDK for API integration. The Live Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
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
}
Response Example
For global system error descriptions, see Global Error Description
Success example (test example channel ID hidden)
{
"code": 200,
"status": "success",
"requestId": "ddf972812a804e0ba9122fd721274592.69.16590638894645319",
"data": {
"channelId": ******,
"name": "MR直播接口测试",
"userId": "1b448be323",
"channelPasswd": "9cNkSc",
"assistantAccount": "0013265559",
"assistantPasswd": "38kYPY"
},
"success": true
}
Error example
{
"code": 400,
"status": "error",
"requestId": "4081dbac03e6441e8bdd301d8feee5a2.124.16360831818611581",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}
