/
livevideosolution_queryvideo_demo.go
52 lines (45 loc) · 1.42 KB
/
livevideosolution_queryvideo_demo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"encoding/json"
"fmt"
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/livevideosolution"
request2 "github.com/yidun/yidun-golang-sdk/yidun/service/antispam/livevideosolution/query/v1/request"
"log"
"os"
)
func main() {
// Create a AntispamRequester instance, the parameters need to pass in the secretId, secretKey distributed by Antispam.
YourSecretId := os.Getenv("SECRET_ID")
YourSecretKey := os.Getenv("SECRET_KEY")
request := request2.NewLiveWallSolutionQueryImageV1Req()
// 设置查询开始时间和结束时间
request.SetStartTime(1701422688000)
request.SetEndTime(1701422868000)
request.SetTaskId("YourTaskId")
request.SetPageNum(1)
request.SetPageSize(10)
// 实例化一个 Client,入参需要传入易盾内容安全分配的secretId,secretKey
client := livevideosolution.NewLiveVideoSolutionClientWithAccessKey(YourSecretId, YourSecretKey)
response, err := client.QueryImage(request)
if err != nil {
// 处理错误并打印日志
log.Fatal(err)
}
if response.GetCode() == 200 {
if response.Result == nil {
fmt.Println("response empty")
return
}
data := response.Result
jsonBytes, err := json.Marshal(data)
if err != nil {
fmt.Println("转换为JSON时出错:", err)
return
}
jsonStr := string(jsonBytes)
fmt.Println(jsonStr)
} else {
fmt.Println("error code: ", response.GetCode())
fmt.Println("error msg: ", response.GetMsg())
}
}