1、接口用于设置某频道播放器的片头广告
2、接口URL中的{channelId}为 频道ID
3、接口支持https
http://api.polyv.net/live/v2/channelAdvert/{channelId}/updateHead
{
"code": 200,
"status": "success",
"message": "",
"data": true
}
{
"code": 400,
"status": "error",
"message": "appId is required.",
"data": ""
}
{
"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 advert type",
"data": ""
}
{
"code": 400,
"status": "error",
"message": "invalid enabled value",
"data": ""
}
{
"code": 403,
"status": "error",
"message": "operation forbidden.",
"data": ""
}
<?php
//引用config.php
include 'config.php';
//接口需要的参数(非sign)赋值
$channelId="123713";
$headAdvertType = "none";
$headAdvertMediaUrl = "http://www.headAdvertMediaUrl.com";
$headAdvertHref = "http://www.headAdvertHref.com";
$headAdvertDuration = 50;
$headAdvertWidth = 100;
$headAdvertHeight = 200;
$params = array(
'appId' => $appId,
'timestamp' => $timestamp,
'headAdvertType' => $headAdvertType,
'headAdvertMediaUrl' => $headAdvertMediaUrl,
'headAdvertHref' => $headAdvertHref,
'headAdvertDuration' => $headAdvertDuration,
'headAdvertWidth' => $headAdvertWidth,
'headAdvertHeight' => $headAdvertHeight
);
//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
$url="http://api.polyv.net/live/v2/channelAdvert/".$channelId."/updateHead";
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);
?>