媒资分类

本文为您提供了C/C++ SDK媒资分类模块相关功能的API调用示例,包含创建分类、删除分类、修改分类、查寻分类及其子分类。

初始化客户端

使用前请先初始化客户端,请参见初始化

创建分类

调用AddCategory接口,完成创建分类功能。

接口参数和返回字段请参见AddCategory。调用示例如下:

#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"

/*创建分类函数*/
VodApiResponse addCategory(VodCredential authInfo) {
    string apiName = "AddCategory";
    map<string, string> args;
    // 父分类ID,若不填,则默认生成一级分类,根节点分类ID为-1
    args["ParentId"] = "-1";
    // 分类名称,不能超过64个字节,UTF8编码
    args["CateName"] = "CateName";
    return getAcsResponse(authInfo, apiName, args);
}

// 请求示例
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = addCategory(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

修改分类

调用UpdateCategory接口,完成修改分类功能。

接口参数和返回字段请参见UpdateCategory。调用示例如下:

#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"

/*修改分类函数*/
VodApiResponse updateCategory(VodCredential authInfo) {
    string apiName = "UpdateCategory";
    map<string, string> args;
    args["CateId"] = "<CateId>";
    // 分类名称,不能超过64个字节,UTF8编码
    args["CateName"] = "CateName";
    return getAcsResponse(authInfo, apiName, args);
}

// 请求示例
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = updateCategory(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

删除分类

调用DeleteCategory接口,完成删除分类功能。

接口参数和返回字段请参见DeleteCategory。调用示例如下:

#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"

/*删除分类函数*/
VodApiResponse deleteCategory(VodCredential authInfo) {
    string apiName = "DeleteCategory";
    map<string, string> args;
    args["CateId"] = "<CateId>";
    return getAcsResponse(authInfo, apiName, args);
}

// 请求示例
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = deleteCategory(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

查询分类及其子分类

调用GetCategories接口,完成查询分类及其子分类功能。

接口参数和返回字段请参见GetCategories。调用示例如下:

#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"

/*查询分类及其子分类函数*/
VodApiResponse getCategories(VodCredential authInfo) {
    string apiName = "GetCategories";
    map<string, string> args;
    args["CateId"] = "<CateId>";
    args["PageNo"] = "1";
    args["PageSize"] = "10";
    return getAcsResponse(authInfo, apiName, args);
}

// 请求示例
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = getCategories(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}
阿里云首页 视频点播 相关技术圈