根據直播頻道及場次和影片ID查詢直播轉存影片相關資訊
更新時間:2022-05-16 10:08:41
介面URL
http://api.polyv.net/v2/video/{userid}/get-live-playback
介面說明
根據直播頻道及場次和影片ID查詢直播轉存影片相關資訊
支援格式
JSON
請求方式
POST,GET
請求數限制
TRUE
請求參數
| 參數名 | 必選 | 類型及範圍 | 說明 |
|---|---|---|---|
| userid | true | string | POLYV使用者ID |
| ptime | true | string | 當前時間的毫秒級時間戳(13位),3分鐘內有效 |
| channelId | false | int | 直播頻道,例如:100000 |
| sessionId | false | string | 直播的場次ID |
| vid | false | string | 點播的影片ID,當這個查詢欄位不為空時,將忽略其他的查詢條件 |
| sign | true | string | 簽名,為40位大寫的SHA1值 |
PHP範例程式碼
<?php
$userid="9f1e0689e1";//必选
$channelId=100000;
$ptime=time()*1000;//必选
$sessionId="xxxfjkddk9";
$vid="b0f7041324572aa5df1e91a971d3ec15_b"
$secretkey="secretkey";
$post_data = array (
"channelId" => $channelId,
"ptime" => $ptime,
"vid" => $vid,
"sessionId" => $sessionId
);
$str="";
foreach ($post_data as $key => $value){
if (!empty($value)) {
$str.=$key."=".$value."&";
}else{
unset($post_data[$key]);
}
}
$str=substr($str, 0,strlen($str)-1);
$str.=$secretkey;
// echo $str;
// die();
$hash=strtoupper(sha1($str));
$post_data["sign"] = $hash;
// var_dump($post_data);
// exit();
$url="http://api.polyv.net/v2/video/{$userid}/get-live-playback";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch);
curl_close($ch);
print_r($output);
?>
回傳結果
JSON範例
{
"code": 200,
"status": "success",
"message": "success",
"data": [
{
"vid": "b0f7041324bdb24f8948d44c84364d1b_b",
"fileSize": 91413940,
"fileUrl": "http://dl.videocc.net/b0f7041324/none_b0f7041324bdb24f8948d44c84364d1b_b_1.mp4",
"sessionId": "f5868alc4s",
"type": "alone",
"channelId": 206204
}
]
}
欄位說明
| 欄位 | 說明 |
|---|---|
| code | 回傳碼 |
| status | 回傳狀態 |
| message | 回傳資訊 |
| vid | 影片id |
| fileSize | 檔案大小,單位為B |
| fileUrl | 檔案下載地址 |
| type | 頻道的類型,alone為一般直播,ppt為三分屏 |
| sessionId | 直播頻道的場次ID |
| channelId | 直播頻道ID |
sign的產生規則
channelId=參數&ptime=參數&sessionId=參數secureKey經過SHA-1加密再經過大寫化 (注意:參數為空時,則在產生sign的時候不需要添加此欄位。例如如果這裡沒有t,則不需要拼接&t=參數)
