接口URL
https://api.polyv.net/live/v3/channel/create-cpic-channel
接口说明
1、接口用于创建频道
2、接口支持https
请求方式
请求参数
响应成功JSON示例:
// 创建成功
{
"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"
}
}
响应失败JSON示例:
// 签名错误
{
"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": ""
}
字段说明
php请求示例
<?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;
?>