Set Player Pause Ad
Updated: 2023-11-14 14:07:19
Interface Description
1、接口用于设置某频道播放器的暂停广告
2、接口URL中的{channelId}为 频道ID
3、接口支持https
Interface URL
http://api.polyv.net/live/v2/channelAdvert/{channelId}/updateStop
Request Method
POST
Supported Format
JSON
Request Limit
TRUE
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | Yes | string | Obtained from API settings, the appId registered in the live streaming system |
| timestamp | Yes | string | Current 13-digit millisecond timestamp, valid within 3 minutes |
| sign | Yes | string | Signature, 32-bit uppercase MD5 value |
| enabled | No | string | Y - enable, N - disable; when setting the switch, other setting parameters are invalid |
| stopAdvertImage | No | string | Image URL, leave blank to delete |
| stopAdvertHref | No | string | Click image redirect URL |
Successful Response JSON Example:
{
"code": 200,
"status": "success",
"message": "",
"data": true
}
Failed Response JSON Example:
No appId entered
{
"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": ""
}
Channel does not exist
{
"code": 400,
"status": "error",
"message": "channel not found.",
"data": ""
}
Switch parameter error
{
"code": 400,
"status": "error",
"message": "invalid enabled value",
"data": ""
}
Illegal request
{
"code": 403,
"status": "error",
"message": "operation forbidden.",
"data": ""
}
Field Description
| Parameter | Description |
|---|---|
| code | Request result code, 200 for success, 400 for error, 403 for signature error |
| status | Request result, "success" for success, "error" for error |
| message | Error message, empty string on success, error message on failure |
| data | true on success, empty string on error |
PHP Request Example
<?php
//引用config.php
include 'config.php';
$stopAdvertImage = "http://www.image.com";
$stopAdvertHref = "http://www.href.com";
$channelId="123713";
$params = array(
'appId' => $appId,
'timestamp' => $timestamp,
'stopAdvertImage' => $stopAdvertImage,
'stopAdvertHref' => $stopAdvertHref
);
//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
$url="http://api.polyv.net/live/v2/channelAdvert/".$channelId."/updateStop";
function post($url, $post_data = '', $timeout = 5){
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, 1);
if($post_data != ''){
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_HEADER, false);
$file_contents = curl_exec($ch);
curl_close($ch);
return $file_contents;
}
$params["sign"] = $sign;
echo post($url, $params);
?>
