全部产品
云市场

媒资分类

更新时间:2018-12-30 17:41:45

初始化客户端

使用前请先初始化客户端,参考 initVodClient 接口。

创建分类

接口参数和返回字段请参考 AddCategory

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("AddCategory", {
  4. ParentId: -1, // 父分类ID,若不填,则默认生成一级分类,根节点分类ID为-1
  5. CateName: '分类名称' // 分类名称
  6. }, {}).then(function (response) {
  7. if (response.Category){
  8. // 创建成功的分类信息
  9. console.log('ParentId = ' + response.Category.ParentId);
  10. console.log('CateId = ' + response.Category.CateId);
  11. console.log('CateName = ' + response.Category.CateName);
  12. console.log('Level = ' + response.Category.Level);
  13. }
  14. console.log('RequestId = ' + response.RequestId);
  15. }).catch(function (response) {
  16. console.log('ErrorCode = ' + response.data.Code);
  17. console.log('ErrorMessage = ' + response.data.Message);
  18. console.log('RequestId = ' + response.data.RequestId);
  19. });

修改分类

接口参数和返回字段请参考 UpdateCategory

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("UpdateCategory", {
  4. CateId: -1, // 分类ID
  5. CateName: '分类名称2' // 分类名称
  6. }, {}).then(function (response) {
  7. console.log('RequestId = ' + response.RequestId);
  8. }).catch(function (response) {
  9. console.log('ErrorCode = ' + response.data.Code);
  10. console.log('ErrorMessage = ' + response.data.Message);
  11. console.log('RequestId = ' + response.data.RequestId);
  12. });

删除分类

接口参数和返回字段请参考 DeleteCategory

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("DeleteCategory", {
  4. CateId: -1 // 分类ID
  5. }, {}).then(function (response) {
  6. console.log('RequestId = ' + response.RequestId);
  7. }).catch(function (response) {
  8. console.log('ErrorCode = ' + response.data.Code);
  9. console.log('ErrorMessage = ' + response.data.Message);
  10. console.log('RequestId = ' + response.data.RequestId);
  11. });

查询分类及其子分类

接口参数和返回字段请参考 GetCategories

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("GetCategories", {
  4. CateId: -1,
  5. PageNo: 1,
  6. PageSize: 10
  7. }, {}).then(function (response) {
  8. // 指定的分类信息
  9. if (response.Category){
  10. console.log('ParentId = ' + response.Category.ParentId);
  11. console.log('CateId = ' + response.Category.CateId);
  12. console.log('CateName = ' + response.Category.CateName);
  13. console.log('Level = ' + response.Category.Level);
  14. console.log('SubTotal = ' + response.SubTotal);
  15. }
  16. if (response.SubCategories && response.SubCategories.Category && response.SubCategories.Category.length > 0){
  17. for (var i=0; i<response.SubCategories.Category.length; i++){
  18. var subCategory = response.SubCategories.Category[i];
  19. console.log('SubCategories.ParentId = ' + subCategory.ParentId);
  20. console.log('SubCategories.CateId = ' + subCategory.CateId);
  21. console.log('SubCategories.CateName = ' + subCategory.CateName);
  22. console.log('SubCategories.Level = ' + subCategory.Level);
  23. }
  24. }
  25. console.log('RequestId = ' + response.RequestId);
  26. }).catch(function (response) {
  27. console.log('ErrorCode = ' + response.data.Code);
  28. console.log('ErrorMessage = ' + response.data.Message);
  29. console.log('RequestId = ' + response.data.RequestId);
  30. });