設定播放器暫停廣告
更新時間:2023-11-14 14:07:19
介面說明
1、接口用于设置某频道播放器的暂停广告
2、接口URL中的{channelId}为 频道ID
3、接口支持https
介面URL
http://api.polyv.net/live/v2/channelAdvert/{channelId}/updateStop
請求方式
POST
支援格式
JSON
請求數限制
TRUE
請求參數
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| appId | 是 | string | 從API設定中取得,在直播系統登記的appId |
| timestamp | 是 | string | 目前13位毫秒級時間戳,3分鐘內有效 |
| sign | 是 | string | 簽名,32位大寫MD5值 |
| enabled | 否 | string | Y-開啟,N-關閉;設定開關時,其餘設定參數無效 |
| stopAdvertImage | 否 | string | 圖片位址,不填代表刪除 |
| stopAdvertHref | 否 | string | 點擊圖片跳轉Url |
回應成功JSON範例:
{
"code": 200,
"status": "success",
"message": "",
"data": true
}
回應失敗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": 400,
"status": "error",
"message": "channel not found.",
"data": ""
}
開關參數錯誤
{
"code": 400,
"status": "error",
"message": "invalid enabled value",
"data": ""
}
非法請求
{
"code": 403,
"status": "error",
"message": "operation forbidden.",
"data": ""
}
欄位說明
| 參數名 | 說明 |
|---|---|
| code | 請求結果代碼,成功為200 錯誤為400,簽名錯誤為403 |
| status | 請求結果,成功時為"success"錯誤時為"error" |
| message | 錯誤資訊,請求成功時為空字串,錯誤時錯誤資訊 |
| data | 請求成功為true,錯誤為空字串 |
php請求範例
<?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);
?>
