Modify Advertisement
Updated: 2023-02-02 10:14:18
Interface Description
1、通过广告id修改广告设置
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
Interface URL
http://api.polyv.net/v2/advertising/{userid}/edit
Request Method
POST
Interface Constraints
- The interface supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| userid | true | String | POLYV VOD account ID. Refer to Get Secret Key for acquisition. Path: Official Website -> Login -> VOD (API Interface) |
| ptime | true | Long | Current time in milliseconds timestamp, valid for 3 minutes |
| sign | true | String | Signature, a 40-character uppercase SHA1 value. The secretkey used to generate the signature is critical for communication data security. It must not be stored 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 for response data. See Signature Generation Rules |
| adid | true | String | Advertisement ID. Refer to Query Advertisement List for acquisition |
| startDate | false | String | Advertisement start date, format: yyyy-MM-dd, e.g., 2021-04-07 |
| endDate | false | String | Advertisement end date, format: yyyy-MM-dd, e.g., 2021-04-10 |
| title | false | String | Advertisement title |
| file | false | File | Advertisement material Pre-roll and post-roll ads support: JPEG, GIF, PNG, FLV, MP4 Pause ads support: SWF, PNG, JPEG, GIF Popup ads support: PNG, JPEG, GIF |
| size | false | Integer | Advertisement duration in seconds. Required for all ad types except when the location parameter is set to pause ad |
| cataids | false | String | Category IDs. Separate multiple categories with commas. Default value is 1 (default category) |
| location | false | Integer | Advertisement type. Default is pre-roll 1: Pre-roll 2: Pause 3: Post-roll 4: Popup |
| popLocation | false | Integer | Popup ad position. Required when location is popup 1: Bottom right 2: Top right 3: Bottom left 4: Top left |
| popUpTime | false | Integer | Time when popup appears, in seconds. Required when location is popup |
| status | false | Integer | Advertisement status. Default is online 10: Online 1: Pending online 0: Offline |
| upTime | false | String | Advertisement start time, format: HH:mm:ss. Default: 00:00:00 |
| offTime | false | String | Advertisement end time, format: HH:mm:ss. Default: 23:59:59 |
| note | false | String | Advertisement description |
| skipAd | false | String | Whether to enable skip ad. Only valid when location is pre-roll. Default: N Y: Enable N: Disable |
| skipOffset | false | String | Seconds after which skipping is allowed. Required when skipAd is Y |
| skipButtonLabel | false | String | Skip button label. Default: Skip |
Example
http://api.polyv.net/v2/advertising/1b448be323/edit
Form Parameters:
note=%E6%B5%8B%E8%AF%95%E4%B8%8B%E4%BF%AE%E6%94%B9%E5%B9%BF%E5%91%8A&endDate=2021-04-10&popLocation=1&sign=61AAC2C374DB0FB93EF83EF1B4FC632191C75864&title=%E6%B5%8B%E8%AF%95%E4%BF%AE%E6%94%B9%E5%B9%BF%E5%91%8A&upTime=15%3A00%3A00&cataids=1615286323771&adid=4229e33f07c141ef96b7&popUpTime=2&size=5&location=4&offTime=15%3A50%3A00&ptime=1617872873234&startDate=2021-04-07&status=10
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code. 200 indicates success, non-200 indicates failure. See Global Error Description |
| status | String | Response status text |
| message | String | Response description. When code is 400 or 500, provides auxiliary error reason |
| data | Object | Returns true on success, empty on failure |
Error Code List
| Response Code | message | Description |
|---|---|---|
| 400 | sign can not be empty. | Signature is empty |
| 400 | ptime is too old. | Timestamp expired |
| 400 | ptime is illegal. | Timestamp format is incorrect or exceeds current time by 3 minutes |
| 400 | Could not find user by userid. | userid does not exist |
| 400 | the sign is not right. | Signature is incorrect |
| 400 | file is empty. | No file uploaded or file is empty |
| 400 | illegal file type. | Illegal file type |
| 400 | upload file failed. | File upload failed |
| 400 | startDate or endDate error. | Date format is incorrect or start date is greater than end date |
| 400 | upTime or offTime error. | Time format is incorrect or start time is greater than end time |
| 400 | param status can not be empty. | Advertisement status cannot be empty |
| 400 | title can not be empty. | Advertisement title cannot be empty |
| 400 | cataids length is not right. | Incorrect number of categories |
| 400 | exist the same cataid. | Duplicate cataid exists |
| 400 | cataid type error. | cataid type error |
| 400 | cata not exist. | Category does not exist |
| 400 | cata conflict. | Parent and child categories cannot exist simultaneously |
| 400 | param location error. | Advertisement type error |
| 400 | param addrurl error. | Link address error |
| 400 | pop location error. | Popup position error |
| 400 | pop up time error. | Popup appearance time error |
| 400 | admatter is not exist. | Advertisement does not exist |
| 400 | illegal skipOffset. | Skip ad enabled but skipOffset parameter is incorrect (must not be less than 0 or greater than ad duration) |
| 400 | location type not supported to skipAd. | Advertisement type does not support skip ad |
| 400 | save fail. | Server exception caused failure |
Java Request Example
For quick integration of basic code, download the relevant dependency source code. Click to download source code. After downloading, add it to your own source code project. HttpUtil.java and VodSignUtil.java in the test cases are included in the download file.
It is strongly recommended to use the VOD Java SDK for API integration. The VOD Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pool.
private static final Logger log = LoggerFactory.getLogger(VodVideoAdvertising.class);
/**
* 修改广告
*/
@Test
public void testModifyAdvertising() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userid = super.userId;
String ptime = String.valueOf(System.currentTimeMillis());
//业务参数
String url = String.format("http://api.polyv.net/v2/advertising/%s/edit", userid);
String adid = "4229e33f07c141ef96b7";
String startDate = "2021-04-07";
String endDate = "2021-04-10";
String title = "测试修改广告";
String advertisingPath = getClass().getResource("/file/").getPath() + "advertisement.jpeg";
File file = new File(advertisingPath);
String size = "5";
String cataids = "1615286323771";
String location = "4";
String popLocation = "1";
String popUpTime = "2";
String status = "10";
String upTime = "15:00:00";
String offTime = "15:50:00";
String note = "测试下修改广告";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("ptime", ptime);
requestMap.put("startDate", startDate);
requestMap.put("endDate", endDate);
requestMap.put("title", title);
Map<String,File> fileMap = new HashMap<>();
fileMap.put("file",file);
requestMap.put("adid",adid);
requestMap.put("size", size);
requestMap.put("cataids", cataids);
requestMap.put("location", location);
requestMap.put("popLocation", popLocation);
requestMap.put("popUpTime", popUpTime);
requestMap.put("status", status);
requestMap.put("upTime", upTime);
requestMap.put("offTime", offTime);
requestMap.put("note", note);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.postFile(url, requestMap,fileMap,Constant.UTF8);
log.debug("测试修改广告,{}", response);
//do somethings
}
Response Example
For global system error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"message": "success",
"data": true
}
Error Example
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
