Polyv Help Center

Help Center

Create Category

Updated: 2025-01-14 15:50:35

API Description

1、创建视频分类
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
4、每个账户预设根目录,名字为默认分类

API URL

http://api.polyv.net/v2/video/{userid}/addCata

Online API Call

Request Method

POST

API Constraints

  1. The API supports both HTTP and HTTPS. HTTPS is recommended to ensure API security. API calls have frequency limits. See details

Request Parameter Description

Parameter Required Type Description
ptime true Long Current time in milliseconds timestamp, valid within 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
cataname true String Category name, no more than 40 characters
parentid true String The parent directory of the new category. A value of 1 indicates the root directory. This parameter is obtained from Get Category and Subcategories
format false String Response data format. Default is JSON format.
xml: returns XML format
json: returns JSON format

Example

http://api.polyv.net/v2/video/1b448be323/addCata

Form Parameters:

sign=672925B1717AD3AB8F39DB0BFBE18B1D82F29B41&cataname=分类名称1&ptime=1617160371881&parentid=1

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 additional error details
data Object Returns detailed category information on success [See data field description](/vod/api/video_management/category/add_category.md?id=data字段说明], returns empty on failure

data Field Description

Field Type Description
cataid Long ID of the newly created category
catatree String Tree path of the newly created category, comma-separated (half-width), e.g., 1b8be3,239c2e

Java Request Example

For quick integration of basic code, please download the relevant dependency source code. Click here to download source code. After downloading, add it to your own source 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 pools.


private static final Logger log = LoggerFactory.getLogger(VodVideoCategoryTest.class);
/**
 * 创建分类
 */
@Test
public void testAddVideoCategory() throws Exception, NoSuchAlgorithmException {
        //公共参数,填写自己的实际参数
        String secretKey = super.secretKey;
        String userId = super.userId;
        String ptime = String.valueOf(System.currentTimeMillis());
        //业务参数
        String url = "http://api.polyv.net/v2/video/" + userId + "/addCata";
        String cataName = "分类名称1";
        String parentId = "1";

        Map<String, String> requestMap = new HashMap<>();
        requestMap.put("ptime", ptime);
        requestMap.put("cataname", cataName);
        requestMap.put("parentid", parentId);
        requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
        String response = HttpUtil.postFormBody(url, requestMap);
        log.debug("测试创建分类,{}", response);
        //do somethings
}

Response Example

For global error descriptions, see Global Error Description

Success Example

{
  "code": 200,
  "status": "success",
  "message": "success",
  "data": {
    "catatree": "1,1617160372987",
    "cataid": 1617160372987
  }
}

Error Example

{
  "code": 400,
  "status": "error",
  "message": "没有填写栏目名称",
  "data": ""
}
联系客服,在线咨询