Get a One-Time Viewing Page URL
Updated: 2022-09-02 18:08:07
Interface URL
https://api.polyv.net/live/v3/channel/watch/get-token-watch-url
Interface Description
1、获取一次性的观看页观看地址URL
2、接口支持https协议
Request Method
GET POST
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | Yes | string | Obtained from API settings, the appId registered in the live streaming system |
| channelId | Yes | int | Channel ID |
| sign | Yes | String | Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must never be saved or used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server and obtain response data. See Signature Generation Rules for details |
| timestamp | Yes | long | Current 13-digit millisecond timestamp, valid for 3 minutes |
Successful Response JSON Example:
{
"code": 200,
"status": "success",
"message": "",
"data": "https://live1.polyv.cn/watch/450698?token=8b01210642bd4c0589cf6c2a09506399"
}
Failed Response JSON Example:
appId not provided
{
"code": 400,
"status": "error",
"message": "appId is required.",
"data": ""
}
Incorrect appId
{
"code": 400,
"status": "error",
"message": "application not found.",
"data": ""
}
Timestamp error
{
"code": 400,
"status": "error",
"message": "invalid timestamp.",
"data": ""
}
Signature error
{
"code": 403,
"status": "error",
"message": "invalid signature.",
"data": ""
}
Field Description
| Parameter | Description |
|---|---|
| code | Request status response code |
| status | Request status |
| message | Error message |
| data | One-time viewing page URL. The generated URL is valid for one hour and becomes invalid once used. |
PHP Request Example
<?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;
?>
