取得一次性觀看頁網址
更新時間:2022-09-02 18:08:07
介面URL
https://api.polyv.net/live/v3/channel/watch/get-token-watch-url
介面說明
1、获取一次性的观看页观看地址URL
2、接口支持https协议
請求方式
GET POST
請求參數
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| appId | 是 | string | 從API設定中取得,在直播系統登記的appId |
| channelId | 是 | int | 頻道ID |
| sign | 是 | String | 簽名,為32位大寫的MD5值,產生簽名的appSecret金鑰作為通訊資料安全的關鍵資訊,嚴禁儲存在用戶端直接使用,所有API都必須透過客戶自己伺服器中轉呼叫POLYV伺服器取得回應資料【詳見簽名產生規則】 |
| timestamp | 是 | long | 目前13位毫秒級時間戳,3分鐘內有效 |
回應成功JSON範例:
{
"code": 200,
"status": "success",
"message": "",
"data": "https://live1.polyv.cn/watch/450698?token=8b01210642bd4c0589cf6c2a09506399"
}
回應失敗JSON範例:
未輸入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": 403,
"status": "error",
"message": "invalid signature.",
"data": ""
}
欄位說明
| 參數名 | 說明 |
|---|---|
| code | 請求狀態回應碼 |
| status | 請求狀態 |
| message | 錯誤訊息 |
| data | 一次性的觀看網址url ,產生的url的有效期為一個小時,一旦使用過就失效了。 |
php請求範例
<?php
//引用config.php
include 'config.php';
$params = array(
'appId' => $appId,
'timestamp' => $timestamp,
'channelId' => $channelId
);
//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
$params['sign'] = $sign;
$url = "https://api.polyv.net/live/v3/channel/watch/get-token-watch-url?".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;
?>
