保利威文档中心

幫助中心

建立頻道介面

更新時間:2022-09-02 18:08:07

介面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;
?>
联系客服,在线咨询