Create Channel API
Updated: 2022-09-02 18:08:07
API URL
https://api.polyv.net/live/v3/channel/create-cpic-channel
API Description
1、接口用于创建频道
2、接口支持https
Request Method
POST
Request Parameters
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| appId | Yes | string | Obtained from API settings, the appId registered in the live streaming system |
| timestamp | Yes | long | Current 13-digit millisecond timestamp, valid for 3 minutes |
| sign | Yes | 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 stored 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 to obtain response data. See Signature Generation Rules |
| name | Yes | string | Channel name, limited to 60 characters |
| scene | Yes | string | Live streaming scene: ppt for three-panel, alone for standard live streaming |
| channelObject | Yes | string | Channel attribute: in for internal, out for external |
| startTime | No | long | Live streaming start time, 13-digit timestamp |
| endTime | No | long | Live streaming end time, 13-digit timestamp |
| authSecretKey | No | String | secretKey used to request user information |
| airUrl | No | String | Custom API URL for retrieving user information |
| airRedirectUrl | No | String | Viewers directly accessing the Polyv watch page will be redirected to this URL |
| coverImage | No | string | Channel cover image URL. To upload an image, first use the upload image API: Upload Image Resource to obtain the image URL for setting the channel cover |
Successful Response JSON Example:
// 创建成功
{
"code":200,
"status":"success",
"message":"",
"data":{
"channelId":1830948,
"passwd":"45a2d6",
"teacherLoginUrl":"https://live.polyv.net/teacher.html",
"teacherClientUrl":"https://live.polyv.net/start-client.html?channelId=1830948",
"watchUrl":"https://live.polyv.cn/watch/1830948",
"assistant":{
"passwd":"90983",
"loginUrl":"https://live.polyv.net/teacher.html",
"account":"0011830948"
},
"guest":{
"webStartUrl":"https://live.polyv.net/web-start/guest?channelId=0051830948",
"passwd":"098653",
"account":"0051830948"
},
"authSecretKey":"fp4mt33n3h"
}
}
Failed Response JSON Example:
// 签名错误
{
"code": 403,
"status": "error",
"message": "invalid signature.",
"data": ""
}
// 未输入appId
{
"code": 400,
"status": "error",
"message": "appId is required.",
"data": ""
}
// appId不正确
{
"code": 400,
"status": "error",
"message": "application not found.",
"data": ""
}
// 时间戳错误
{
"code": 400,
"status": "error",
"message": "invalid timestamp.",
"data": ""
}
// 频道名称是必须
{
"code": 400,
"status": "error",
"message": "channel name is required.",
"data": ""
}
// 频道名称过长
{
"code": 400,
"status": "error",
"message": "channel name is over length.",
"data": ""
}
// channelObject非法
{
"code": 400,
"status": "error",
"message": "channelobject not right.",
"data": ""
}
// 非法的直播场景值
{
"code": 400,
"status": "error",
"message": "scene not right.",
"data": ""
}
// 超过了能创建的频道数的最大值
{
"code": 400,
"status": "error",
"message": "cannot create more than xx channels.",
"data": ""
}
Field Description
| Parameter Name | Description |
|---|---|
| code | Response code: 200 for success, 400 for failure, 403 for signature error, 500 for exception error |
| status | success for success, error for failure |
| message | Error message when status is error |
| data | Response data |
| channelId | Channel ID |
| passwd | Channel password |
| teacherLoginUrl | Presenter login URL |
| teacherClientUrl | Presenter client launch link |
| watchUrl | Watch URL |
| authSecretKey | secretKey for requesting user information API |
| assistant | Assistant related information |
| assistant.account | Assistant account |
| assistant.passwd | Assistant password |
| assistant.loginUrl | Assistant login URL |
| guest | Guest related information |
| guest.account | Guest account |
| guest.passwd | Guest password |
| guest.webStartUrl | Guest web broadcast start URL |
PHP Request Example
<?php
//引用config.php
include 'config.php';
$params = array(
'appId' => $appId,
'timestamp' => $timestamp,
'name' => 'channel name',
'channelObjet' => 'in',
'startTime' => 133333345553,
'endTime' => 133333345553,
'coverImage' => 133333345553,
'scene' => 'alone'
);
//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
$params['sign'] = $sign;
$url = "http://api.polyv.net/live/v3/channel/create-cpic-channel?".http_build_query($params);
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
$res = curl_exec($curl);
curl_close($curl);
echo $res;
?>
