查詢廣告列表
更新時間:2023-02-02 10:14:18
介面描述
1、分页获取广告列表详情
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
介面URL
http://api.polyv.net/v2/advertising/{userid}/list
請求方式
GET
介面限制
1、介面同時支援HTTP、HTTPS,建議使用HTTPS確保介面安全,介面呼叫有頻率限制,詳細請查看
請求參數描述
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| userid | true | String | 保利威點播帳戶id,可參考【取得金鑰】取得,取得路徑:官網->登入->點播(API介面) |
| ptime | true | Long | 目前時間的毫秒級時間戳,3分鐘內有效 |
| sign | true | String | 簽名,為40位大寫的SHA1值,產生簽名的secretkey金鑰作為通訊資料安全的關鍵資訊,嚴禁儲存在用戶端直接使用,所有API都必須透過客戶自己伺服器中轉呼叫POLYV伺服器取得回應資料【詳見簽名產生規則】 |
| page | false | String | 第幾頁,預設第一頁 |
| pageSize | false | String | 每頁顯示幾條,預設10條 |
範例
http://api.polyv.net/v2/advertising/1b448be323/list?sign=06423AE4F3EE1959F29E5723A43F731897B0B6F8&pageSize=1&page=1&ptime=1617777684134
回應參數描述
| 參數名 | 類型 | 說明 |
|---|---|---|
| code | Integer | 回應狀態碼,200為成功返回,非200為失敗【詳見全域錯誤說明】 |
| status | String | 回應狀態文字資訊 |
| message | String | 回應描述資訊,當code為400或500時,輔助描述錯誤原因 |
| data | Object | 回應成功時返回廣告資訊【詳見Data欄位說明】,回應失敗時返回空 |
Data參數描述
| 欄位 | 類型 | 說明 |
|---|---|---|
| pageNumber | Integer | 目前的頁數 |
| totalItems | Integer | 總的條數 |
| contents | Array | 查詢的結果列表【詳見Contents欄位說明】 |
| firstPage | Boolean | 是否為第一頁,值為:true/false |
| lastPage | Boolean | 是否為最後一頁,值為:true/false |
| nextPageNumber | Integer | 下一頁編號 |
| prePageNumber | Integer | 上一頁編號 |
| totalPages | Integer | 總頁數 |
| startRow | Integer | 目前頁第一條記錄在總記錄中的位置 |
| endRow | Integer | 目前頁最後一條記錄在總記錄中的位置 |
| limit | Integer | 目前頁記錄個數 |
| activePageNum | Integer | 實際頁碼 |
| offset | Integer | 分頁起始記錄 |
Contents參數描述
| 欄位 | 類型 | 說明 |
|---|---|---|
| adid | String | 廣告id |
| title | String | 廣告標題 |
| note | String | 廣告描述 |
| userid | String | 使用者ID |
| location | String | 廣告類型 1:片頭 2:暫停 3:片尾 4:彈窗 |
| matterurl | String | 廣告素材地址 |
| size | Integer | 廣告時長,單位秒 |
| playnum | Integer | 廣告播放次數 |
| addrurl | String | 廣告點擊連結 |
| isstatis | Integer | 廣告是否懸浮 1:是 2:不是 |
| uptime | Long | 廣告開始時間,8位毫秒級時間戳 |
| offtime | Long | 廣告結束時間,8位毫秒級時間戳 |
| startdate | Long | 廣告投放開始日期,13位毫秒級時間戳 |
| enddate | Long | 廣告投放結束日期,13位毫秒級時間戳 |
| ptime | Long | 修改時間,13位毫秒級時間戳 |
| status | Integer | 廣告狀態 10:已上線 1:待上線 0:已下線 |
| popuptime | Long | 廣告彈窗出現時間 |
| cataids | Long | 分類id,多個分類id,以英文逗號分隔,預設值為1,1是預設分類 |
| poplocation | Integer | 廣告彈窗位置,當請求參數location為彈窗時必填 1:右下角 2:右上角 3:左下角 4:左上角 |
| skiptime | String | 多少秒後允許跳過,僅片頭廣告有效 |
| skipbutton | String | 跳過按鈕標籤名稱,預設為跳過,僅片頭廣告有效 |
| skipenabled | String | 跳過按鈕狀態,僅片頭廣告有效 Y:開啟跳過廣告 N:關閉跳過廣告 |
| cataname | String | 分類名稱,多個以英文逗號分隔,預設值為1,1是預設分類 |
返回錯誤代碼列表
| 錯誤代碼 | 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 | page is illegal | page值非法 |
| 400 | pageSize is illegal | pageSize值非法 |
Java請求範例
快速接入基礎代碼請下載相關依賴原始碼, 點擊下載原始碼 ,下載後加入到自己的原始碼工程中即可。測試用例中的HttpUtil.java 和 VodSignUtil.java 都包含在下載檔案中。
強烈建議您使用點播Java SDK完成API的功能對接,點播Java SDK 對API呼叫邏輯、異常處理、資料簽名、HTTP請求執行緒池進行了統一封裝和最佳化。
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
}
回應範例
系統全域錯誤說明詳見全域錯誤說明
成功範例
{
"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
}
}
異常範例
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
