接口URL
http://api.polyv.net/v2/advertising/{userid}/edit
接口说明
(接口调用有频率限制,详细请查看)
提供修改广告接口
返回结果支持格式
JSON
请求方式
POST
请求参数
参数名 | 必选 | 类型及范围 | 说明 |
---|---|---|---|
userid | true | string | 用户id,路径参数 |
ptime | true | string | 当前13位毫秒级时间戳,3分钟内有效 |
sign | true | string | 签名,40位大写的sha1值 |
adid | true | string | 广告id |
startDate | false | string | 广告开始日期,格式为yyyy-MM-dd |
endDate | false | string | 广告结束日期,格式为yyyy-MM-dd |
title | false | string | 广告标题 |
file | false | file | 广告素材,片头、片尾广告素材支持:JPEG,GIF,PNG,FLV,MP4;暂停广告支持:SWF,PNG,JPEG,GIF;弹窗广告支持PNG,JPEG,GIF. |
size | false | int | 广告时长 |
cataids | false | string | 分类id,关联多分类时,以英文逗号(,)分隔 |
location | false | int | 广告类型,片头-1,暂停-2,片尾-3,弹窗-4 |
popLocation | false | int | 广告弹窗位置,广告类型为弹窗时必填,右下角-1,右上角-2,左下角-3,左上角-4 |
popUpTime | false | int | 弹窗出现的时间,单位秒,广告类型为弹窗时必填 |
status | false | int | 广告状态,已上线-10,待上线-1,已下线-0 |
upTime | false | string | 广告开始时间,格式为HH:mm:ss,默认为00:00:00 |
offTime | false | string | 广告结束时间,格式为HH:mm:ss,默认为23:59:59 |
note | false | string | 广告描述 |
skipAd | false | string | Y表示开启跳过广告,N表示关闭跳过广告。仅片头广告有效 |
skipOffset | false | string | 多少秒后允许跳过,当skipAd为Y时,该字段为必要参数 |
skipButtonLabel | false | string | 跳过按钮标签,默认为跳过 |
返回结果
{
"code": 200,
"status": "success",
"message": "success",
"data": true
}
失败返回json(不带jsonp)
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
响应说明
响应代码 | message | 说明 |
---|---|---|
400 | sign can not be empty. | 加密串为空 |
400 | ptime is too old. | 时间戳过期 |
400 | ptime is illegal. | 时间戳参数格式不对或者超过当前时间3分钟 |
400 | Could not find user by userid. | userid不存在 |
400 | the sign is not right. | 加密串不正确 |
400 | file is empty. | 没上传文件或为空文件 |
400 | illegal file type. | 非法的文件类型 |
400 | upload file failed. | 上传文件失败 |
400 | startDate or endDate error. | 日期格式不正确或开始日期大于结束日期 |
400 | upTime or offTime error. | 时间格式不正确或开始时间大于结束时间 |
400 | param status can not be empty. | 广告状态不能为空 |
400 | title can not be empty. | 广告标题不能为空 |
400 | cataids length is not right. | 分类数量不正确 |
400 | exist the same cataid. | 存在相同的cataid |
400 | cataid type error. | cataid类型错误 |
400 | cata not exist. | 分类不存在 |
400 | cata conflict. | 不能同时存在父分类和子分类 |
400 | param location error. | 广告类型错误 |
400 | param addrurl error. | 链接地址错误 |
400 | pop location error. | 弹窗位置错误 |
400 | pop up time error. | 弹窗出现时间错误 |
400 | admatter is not exist. | 广告不存在 |
400 | illegal skipOffset. | 开启了跳过广告,但skipOffset参数不正确(不得小于0或大于广告时长) |
400 | location type not supported to skipAd. | 广告类型不支持开启跳过广告 |
400 | save fail. | 服务器异常导致失败 |
200 | success | 提交成功 |
PHP请求示例
<?php
header("Content-type: text/html; charset=utf-8");
$userid="用户id";
$secretkey="用户secretkey";
$params = array(
'ptime' => time()*1000,
'adid' => 'a205e415d05a42ca8d60',
'title' => '只修改title'
);
# 创建排序后的字典
foreach ($params as $key=>$value){
$arr[$key] = $key;
}
sort($arr);
$str='';
$length=count($arr);
foreach ($arr as $k => $v) {
$str = $str.$v.'='.$params[$v];
if($k < $length-1) {
$str = $str.'&';
}
}
$hash=strtoupper(sha1($str.$secretkey));
$params['sign']=$hash;
$url="http://api.polyv.net/v2/advertising/${userid}/edit?".http_build_query($params);
?>
<html>
<form action="<?php echo $url?>" method="post" enctype='multipart/form-data' >
文件:<input type="file" name="file" id="image" /><br>
<input type="submit" value="点击上传"/>
</form>
</html>
签名规则:
将非空的请求参数按照参数名字典顺序排列,连接参数名与参数值,并在尾部加上secretkey,生成40位大写SHA1值,作为sign。 以下是示例过程:
1、请求参数为
ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"
format = "json"
2、将请求参数按照参数名字典顺序排列
format = "json"
ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"
3、连接字符串
连接参数名与参数值,并在尾部加上secretkey(secretkey的值为tIQp4ATe9Z),如下:
format=json&ptime=1492591990000&vid=382839019131be68715e9455f8d0971a_3tIQp4ATe9Z
4、生成签名sign
50BF9B165630A8047EB1D17D95A469CC51FF754E