Query Ad List
Updated: 2025-01-14 16:11:36
API Description
1、分页获取广告列表详情
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
API URL
http://api.polyv.net/v2/advertising/{userid}/list
Request Method
GET
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended to ensure API security. API calls have a frequency limit. See details
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| ptime | true | Long | Current time in milliseconds, 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 directly on the client. 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 |
| page | false | String | Page number, default is the first page |
| pageSize | false | String | Number of items per page, default is 10 |
Example
http://api.polyv.net/v2/advertising/1b448be323/list?sign=06423AE4F3EE1959F29E5723A43F731897B0B6F8&pageSize=1&page=1&ptime=1617777684134
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, it provides additional error details |
| data | Object | Returns ad information on success See Data field description, returns empty on failure |
Data Parameter Description
| Field | Type | Description |
|---|---|---|
| pageNumber | Integer | Current page number |
| totalItems | Integer | Total number of items |
| contents | Array | Query result list See Contents field description |
| firstPage | Boolean | Whether it is the first page, value: true/false |
| lastPage | Boolean | Whether it is the last page, value: true/false |
| nextPageNumber | Integer | Next page number |
| prePageNumber | Integer | Previous page number |
| totalPages | Integer | Total number of pages |
| startRow | Integer | Position of the first record on the current page in the total records |
| endRow | Integer | Position of the last record on the current page in the total records |
| limit | Integer | Number of records on the current page |
| activePageNum | Integer | Actual page number |
| offset | Integer | Pagination starting record |
Contents Parameter Description
| Field | Type | Description |
|---|---|---|
| adid | String | Ad ID |
| title | String | Ad title |
| note | String | Ad description |
| userid | String | User ID |
| location | String | Ad type 1: Pre-roll 2: Pause 3: Post-roll 4: Popup |
| matterurl | String | Ad material URL |
| size | Integer | Ad duration, in seconds |
| playnum | Integer | Ad play count |
| addrurl | String | Ad click URL |
| isstatis | Integer | Whether the ad is floating 1: Yes 2: No |
| uptime | Long | Ad start time, 8-digit millisecond timestamp |
| offtime | Long | Ad end time, 8-digit millisecond timestamp |
| startdate | Long | Ad delivery start date, 13-digit millisecond timestamp |
| enddate | Long | Ad delivery end date, 13-digit millisecond timestamp |
| ptime | Long | Modification time, 13-digit millisecond timestamp |
| status | Integer | Ad status 10: Online 1: Pending 0: Offline |
| popuptime | Long | Ad popup appearance time |
| cataids | Long | Category IDs, multiple IDs separated by commas, default is 1 (default category) |
| poplocation | Integer | Ad popup position, required when the request parameter location is popup 1: Bottom right 2: Top right 3: Bottom left 4: Top left |
| skiptime | String | Seconds after which skipping is allowed, only valid for pre-roll ads |
| skipbutton | String | Skip button label text, default is "Skip", only valid for pre-roll ads |
| skipenabled | String | Skip button status, only valid for pre-roll ads Y: Skip ad enabled N: Skip ad disabled |
| cataname | String | Category name, multiple names separated by commas, default is 1 (default category) |
Error Code List
| Error Code | message | Description |
|---|---|---|
| 400 | sign can not be empty. | Signature string is empty |
| 400 | ptime is too old. | Timestamp has expired |
| 400 | ptime is illegal. | Timestamp parameter format is incorrect or exceeds 3 minutes from current time |
| 400 | Could not find user by userid. | User ID does not exist |
| 400 | the sign is not right. | Signature string is incorrect |
| 400 | page is illegal | Page value is invalid |
| 400 | pageSize is illegal | PageSize value is invalid |
Java Request Example
For quick integration of basic code, please download the relevant dependency source code. Click here to download the 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 downloaded file.
It is strongly recommended to use the VOD Java SDK for API integration. The VOD Java SDK provides a unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
private static final Logger log = LoggerFactory.getLogger(VodVideoAdvertising.class);
/**
* 查询广告列表
*/
@Test
public void testGetAdvertising() 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/list", userid);
String page = "1";
String pageSize = "2";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("ptime", ptime);
requestMap.put("page", page);
requestMap.put("pageSize", pageSize);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.get(url, requestMap);
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": {
"pageNumber": 1,
"totalItems": 18,
"contents": [{
"adid": "ea7a04430dd04d01853d",
"title": "测试广告(Junit测试,勿删)",
"note": "测试广告描述",
"userid": "1b448be323",
"location": "1",
"matterurl": "/1b448be323/html/adv/image/1/1b448be323/thumb/5439a04e5f6c40a290822eb4b2d3086c.jpg",
"size": 2,
"addrurl": "https://baidu.com",
"isstatis": 2,
"cpmplay": 0,
"desccpmplay": 1200,
"playnum": 0,
"uptime": -28800000,
"offtime": 57599000,
"startdate": 1616342400000,
"enddate": 1619020800000,
"province": "all",
"country": "",
"ptime": 1619740895366,
"status": 0,
"width": 0,
"height": 0,
"doublenum": 0,
"errornum": 0,
"popuptime": null,
"poplocation": -1,
"cataids": "1",
"skiptime": 1,
"skipbutton": "跳过广告",
"skipenabled": "Y",
"cataname": "视频",
"advurl": "http://img.videocc.net/1b448be323/html/adv/image/1/1b448be323/thumb/5439a04e5f6c40a290822eb4b2d3086c.jpg"
}, {
"adid": "db56c968c10e4c76a758",
"title": "测试广告-弹窗",
"note": "测试广告描述",
"userid": "1b448be323",
"location": "4",
"matterurl": "/1b448be323/html/adv/image/1/1b448be323/thumb/2373551d8e4841be88a4860d8b52ea3d.jpg",
"size": 2,
"addrurl": null,
"isstatis": 2,
"cpmplay": -1,
"desccpmplay": 0,
"playnum": 0,
"uptime": -28800000,
"offtime": 57599000,
"startdate": 1616342400000,
"enddate": 1619020800000,
"province": null,
"country": null,
"ptime": 1619418030516,
"status": 10,
"width": 0,
"height": 0,
"doublenum": 0,
"errornum": 0,
"popuptime": "2",
"poplocation": 4,
"cataids": "1",
"skiptime": 1,
"skipbutton": "跳过广告",
"skipenabled": "N",
"cataname": "视频",
"advurl": "http://img.videocc.net/1b448be323/html/adv/image/1/1b448be323/thumb/2373551d8e4841be88a4860d8b52ea3d.jpg"
}],
"nextPageNumber": 2,
"prePageNumber": 1,
"startRow": 1,
"activePageNum": 1,
"firstPage": true,
"lastPage": false,
"totalPages": 9,
"endRow": 2,
"limit": 2,
"offset": 0
}
}
Error Example
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
