创建频道接口

接口URL

https://api.polyv.net/live/v3/channel/create-cpic-channel

接口说明

1、接口用于创建频道
2、接口支持https

请求方式

POST

请求参数

参数名
必选
类型
说明

appId

string

从API设置中获取,在直播系统登记的appId

timestamp

long

当前13位毫秒级时间戳,3分钟内有效

sign

String

签名,为32位大写的MD5值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据【详见签名生成规则

name

string

频道名称,限制长度为60

scene

string

直播场景,三分屏:ppt,普通直播:alone

channelObject

string

频道属性,in 对内,out 对外

startTime

long

直播开始时间,13位的时间戳

endTime

long

直播结束时间,13位的时间戳

authSecretKey

String

用于请求用户信息的secretKey

airUrl

String

用于获取用户信息的自定义接口地址

airRedirectUrl

String

观众直接访问Polyv观看页,会跳转到该地址

coverImage

string

频道的封面图片地址,如果需要上传图片可以先通过上传图片接口:上传图片资源 得到图片地址用于设置频道的封面图片地址

响应成功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": ""
}

字段说明

参数名
说明

code

响应代码,成功为200,失败为400,签名错误为403,异常错误500

status

成功为success,失败为error

message

错误时为错误提示消息

data

响应数据

channelId

频道ID

passwd

频道密码

teacherLoginUrl

主讲登录地址

teacherClientUrl

主讲人客户端启动链接

watchUrl

观看链接

authSecretKey

请求用户信息接口的secretKey

assistant

助教相关信息

assistant.account

助教账号

assistant.passwd

助教密码

assistant.loginUrl

助教登录地址

guest

嘉宾相关信息

guest.account

嘉宾账号

guest.passwd

嘉宾密码

guest.webStartUrl

嘉宾登录网页开播端地址

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;
?>

Last updated

Was this helpful?