建立分類
更新時間:2022-09-02 18:08:07
介面說明
1、使用子账号创建视频分类
2、接口支持https协议
介面URL
http://api.polyv.net/v3/category/add
請求方式
POST
介面限制
1、介面同時支援HTTP、HTTPS,建議使用HTTPS以確保介面安全,介面呼叫有頻率限制,詳細請查看
請求參數說明
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| appId | true | String | 子帳號appId |
| timestamp | true | Long | 目前時間的毫秒級時間戳記,3分鐘內有效 |
| sign | true | String | 簽名,32位元大寫MD5值【詳見MD5簽名產生規則】 |
| name | true | String | 分類名稱 |
| parentId | false | String | 父分類id,預設為1,表示預設分類 |
範例
http://api.polyv.net/v3/category/add
表單參數:
appId=xxxxxx&name=%E6%B5%8B%E8%AF%95%E5%88%9B%E5%BB%BA%E5%88%86%E7%B1%BB&sign=FC67B8973F35D00F9E843C380880DFFD&parentId=1617850424921×tamp=1617850576238
回應參數說明
| 參數名 | 類型 | 說明 |
|---|---|---|
| code | Integer | 回應狀態碼,200為成功回傳,非200為失敗【詳見全域錯誤說明】 |
| status | String | 回應狀態文字資訊 |
| error | Object | 回應成功回傳null,回應失敗回傳錯誤描述資訊【詳見error參數說明】 |
| requestId | String | 每次請求的業務流水號,必須唯一,便於客戶端/伺服器端排查問題 |
| data | String | 回應成功回傳成功建立的分類id,回應失敗回傳null |
error參數說明
| 欄位 | 類型 | 說明 |
|---|---|---|
| code | Integer | 錯誤碼 |
| desc | String | 錯誤描述 |
Java請求範例
快速接入基礎程式碼請下載相關依賴原始碼, 點擊下載原始碼 ,下載後加入到自己的原始碼工程中即可。測試案例中的HttpUtil.java 和 VodSignUtil.java 都包含在下載檔案中。
強烈建議您使用點播Java SDK完成API的功能對接,點播Java SDK 對API呼叫邏輯、異常處理、資料簽名、HTTP請求執行緒池進行了統一封裝和最佳化。
private static final Logger log = LoggerFactory.getLogger(VodSubAccountTest.class);
/**
* 创建分类
* @throws Exception
* @throws NoSuchAlgorithmException
*/
@Test
public void testSubAddCategory() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/v3/category/add";
String name = "测试创建分类";
String parentId = "1617850424921";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("name", name);
requestMap.put("parentId", parentId);
requestMap.put("sign", VodSignUtil.getSignMd5(requestMap, appSecret));
String response = HttpUtil.postFormBody(url, requestMap);
log.debug("测试创建分类,{}", response);
//do somethings
}
回應範例
系統全域錯誤說明詳見全域錯誤說明
成功範例
{
"requestId": "00543c3f-2d3d-4765-85ca-b332f1021362",
"code": 200,
"status": "success",
"error": null,
"data": 1617850556356
}
異常範例
時間戳記錯誤
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 400,
"status": "error",
"error": {
"code": 100,
"desc": "invalid timestamp"
},
"data": null
}
appId不正確
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 400,
"status": "error",
"error": {
"code": 101,
"desc": "application not exist"
},
"data": null
}
子帳號不存在
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 400,
"status": "error",
"error": {
"code": 102,
"desc": "user children not exist"
},
"data": null
}
子帳號過期
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 403,
"status": "error",
"error": {
"code": 103,
"desc": "user children expired"
},
"data": null
}
簽名錯誤
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 403,
"status": "error",
"error": {
"code": 104,
"desc": "invalid signature"
},
"data": null
}
帳號權限不足
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 403,
"status": "error",
"error": {
"code": 105,
"desc": "permission limited"
},
"data": null
}
分類名稱不能為空
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 400,
"status": "error",
"error": {
"code": 3000,
"desc": "没有填写栏目名称"
},
"data": null
}
父分類不能為空
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 400,
"status": "error",
"error": {
"code": 3001,
"desc": "category not exist"
},
"data": null
}
子帳號沒有權限在該目錄下建立分類
{
"requestId": "5ede3d23-45f0-4661-99be-e95d07daf049",
"code": 400,
"status": "error",
"error": {
"code": 3002,
"desc": "子账号没有权限在该目录下创建分类"
},
"data": null
}
已存在同名的影片分類
{
"requestId": "df5750d9-27b0-4390-ad7c-f0d1f86d0d14",
"code": 400,
"status": "error",
"error": {
"code": 3003,
"desc": "已存在同名的视频分类"
},
"data": null
}
