SubmitOpenClassTask.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
  5. "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
  6. "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
  7. tci "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tci/v20190318"
  8. )
  9. func main() {
  10. credential := common.NewCredential(
  11. // os.Getenv("TENCENTCLOUD_SECRET_ID"),
  12. // os.Getenv("TENCENTCLOUD_SECRET_KEY"),
  13. "", "",
  14. )
  15. cpf := profile.NewClientProfile()
  16. cpf.HttpProfile.ReqMethod = "POST"
  17. cpf.HttpProfile.ReqTimeout = 30
  18. cpf.HttpProfile.Endpoint = "tci.tencentcloudapi.com"
  19. client, _ := tci.NewClient(credential, "ap-guangzhou", cpf)
  20. req := tci.NewSubmitOpenClassTaskRequest()
  21. req.FileContent = common.StringPtr("https://edu-test-1253131631.cos.ap-guangzhou.myqcloud.com/aieduautotest/autotest_vedio.mp4")
  22. req.FileType = common.StringPtr("vod_url")
  23. req.LibrarySet = common.StringPtrs([]string{"library_15603955264181591716"})
  24. // 通过client对象调用想要访问的接口,需要传入请求对象
  25. response, err := client.SubmitOpenClassTask(req)
  26. // 处理异常
  27. fmt.Println(err)
  28. if _, ok := err.(*errors.TencentCloudSDKError); ok {
  29. fmt.Printf("An API error has returned: %s", err)
  30. return
  31. }
  32. // 非SDK异常,直接失败。实际代码中可以加入其他的处理。
  33. if err != nil {
  34. panic(err)
  35. }
  36. // 打印返回的json字符串
  37. fmt.Printf("%s", response.ToJsonString())
  38. }