全部产品
云市场

媒资分类

更新时间:2018-12-30 17:21:04

初始化客户端

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

创建分类

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

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.Sample
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. AddCategoryRequest request = new AddCategoryRequest();
  15. // 父分类ID,若不填,则默认生成一级分类,根节点分类ID为 -1
  16. request.ParentId = -1;
  17. // 分类名称
  18. request.CateName = "catename";
  19. // 初始化客户端
  20. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  21. // 发起请求,并得到 response
  22. AddCategoryResponse response = client.GetAcsResponse(request);
  23. Console.WriteLine("RequestId = " + response.RequestId);
  24. Console.WriteLine("CateId = " + response.Category.CateId);
  25. Console.WriteLine("CateName = " + response.Category.CateName);
  26. Console.WriteLine("ParentId = " + response.Category.ParentId);
  27. }
  28. catch (ServerException ex)
  29. {
  30. Console.WriteLine(ex.ToString());
  31. }
  32. catch (ClientException ex)
  33. {
  34. Console.WriteLine(ex.ToString());
  35. }
  36. }
  37. }
  38. }

修改分类

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

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.Sample
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. UpdateCategoryRequest request = new UpdateCategoryRequest();
  15. // 请设置真实分类ID
  16. request.CateId = -1;
  17. // 分类名称
  18. request.CateName = "new catename";
  19. // 初始化客户端
  20. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  21. // 发起请求,并得到 response
  22. UpdateCategoryResponse response = client.GetAcsResponse(request);
  23. Console.WriteLine("RequestId = " + response.RequestId);
  24. }
  25. catch (ServerException ex)
  26. {
  27. Console.WriteLine(ex.ToString());
  28. }
  29. catch (ClientException ex)
  30. {
  31. Console.WriteLine(ex.ToString());
  32. }
  33. }
  34. }
  35. }

删除分类

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

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.Sample
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. DeleteCategoryRequest request = new DeleteCategoryRequest();
  15. // 设置真实分类ID
  16. request.CateId = -1;
  17. // 初始化客户端
  18. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  19. // 发起请求,并得到 response
  20. DeleteCategoryResponse response = client.GetAcsResponse(request);
  21. Console.WriteLine("RequestId = " + response.RequestId);
  22. }
  23. catch (ServerException ex)
  24. {
  25. Console.WriteLine(ex.ToString());
  26. }
  27. catch (ClientException ex)
  28. {
  29. Console.WriteLine(ex.ToString());
  30. }
  31. }
  32. }
  33. }

查询分类及其子分类

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

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.Sample
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. GetCategoriesRequest request = new GetCategoriesRequest();
  15. // 分类ID,若不填,则默认获取根节点及其子分类,根节点分类ID为-1
  16. request.CateId = -1;
  17. request.PageNo = 1;
  18. request.PageSize = 10;
  19. // 初始化客户端
  20. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  21. // 发起请求,并得到 response
  22. GetCategoriesResponse response = client.GetAcsResponse(request);
  23. Console.WriteLine("RequestId = " + response.RequestId);
  24. // 分类信息
  25. Console.WriteLine("Category.CateId = " + response.Category1.CateId);
  26. Console.WriteLine("Category.CateName = " + response.Category1.CateName);
  27. Console.WriteLine("Category.ParentId = " + response.Category1.ParentId);
  28. Console.WriteLine("SubTotal = " + response.SubTotal);
  29. // 子分类列表
  30. foreach (var subcategory in response.SubCategories)
  31. {
  32. Console.WriteLine("subcategory.CateId = " + subcategory.CateId);
  33. Console.WriteLine("subcategory.CateName = " + subcategory.CateName);
  34. Console.WriteLine("subcategory.ParentId = " + subcategory.ParentId);
  35. }
  36. }
  37. catch (ServerException ex)
  38. {
  39. Console.WriteLine(ex.ToString());
  40. }
  41. catch (ClientException ex)
  42. {
  43. Console.WriteLine(ex.ToString());
  44. }
  45. }
  46. }
  47. }