全部产品
云市场

媒资分类

更新时间:2018-12-29 09:45:31

初始化客户端

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

创建分类

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

  1. package main
  2. import (
  3. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
  5. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
  6. "fmt"
  7. )
  8. func MyAddCategory(client *vod.Client) (response *vod.AddCategoryResponse, err error) {
  9. request := vod.CreateAddCategoryRequest()
  10. request.CateName = "sample category name"
  11. request.ParentId = "-1"
  12. request.AcceptFormat = "JSON"
  13. return client.AddCategory(request)
  14. }
  15. func main() {
  16. client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
  17. if err != nil {
  18. panic(err)
  19. }
  20. response, err := MyAddCategory(client)
  21. if err != nil {
  22. panic(err)
  23. }
  24. fmt.Println(response.GetHttpContentString())
  25. fmt.Println(response.Category.CateId)
  26. }

修改分类

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

  1. package main
  2. import (
  3. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
  5. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
  6. "fmt"
  7. )
  8. func MyUpdateCategory(client *vod.Client) (response *vod.UpdateCategoryResponse, err error) {
  9. request := vod.CreateUpdateCategoryRequest()
  10. request.CateId = "<CateId>"
  11. request.CateName = "sample category name"
  12. request.AcceptFormat = "JSON"
  13. return client.UpdateCategory(request)
  14. }
  15. func main() {
  16. client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
  17. if err != nil {
  18. panic(err)
  19. }
  20. response, err := MyUpdateCategory(client)
  21. if err != nil {
  22. panic(err)
  23. }
  24. fmt.Println(response.GetHttpContentString())
  25. }

删除分类

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

  1. package main
  2. import (
  3. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
  5. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
  6. "fmt"
  7. )
  8. func MyDeleteCategory(client *vod.Client) (response *vod.DeleteCategoryResponse, err error) {
  9. request := vod.CreateDeleteCategoryRequest()
  10. request.CateId = "<CateId>"
  11. request.AcceptFormat = "JSON"
  12. return client.DeleteCategory(request)
  13. }
  14. func main() {
  15. client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
  16. if err != nil {
  17. panic(err)
  18. }
  19. response, err := MyDeleteCategory(client)
  20. if err != nil {
  21. panic(err)
  22. }
  23. fmt.Println(response.GetHttpContentString())
  24. }

查询分类及其子分类

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

  1. package main
  2. import (
  3. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
  5. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
  6. "fmt"
  7. )
  8. func MyGetCategories(client *vod.Client) (response *vod.GetCategoriesResponse, err error) {
  9. request := vod.CreateGetCategoriesRequest()
  10. request.CateId = "<CateId>"
  11. request.PageNo = "1"
  12. request.PageSize = "20"
  13. request.AcceptFormat = "JSON"
  14. return client.GetCategories(request)
  15. }
  16. func main() {
  17. client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
  18. if err != nil {
  19. panic(err)
  20. }
  21. response, err := MyGetCategories(client)
  22. if err != nil {
  23. panic(err)
  24. }
  25. fmt.Println(response.GetHttpContentString())
  26. }