1 Star 0 Fork 0

网易易盾/yidun-golang-sdk

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
label_query_demo.go 1.32 KB
Copy Edit Raw Blame History
fengyunlong authored 2024-01-03 14:06 . 【go语言sdk】第一版v1.0.0
package main
import (
"fmt"
"log"
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/label"
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/label/request"
)
/**
* 反垃圾标签查询demo
*/
func main() {
// 创建一个LabelQueryRequest实例
request := request.NewLabelQueryRequest();
// 实例化Client,入参需要传入易盾内容安全分配的AccessKeyId,AccessKeySecret
labelClient := label.NewLabelClientWithAccessKey("AccessKeyId", "AccessKeySecret")
// 传入请求参数
//设置返回标签的最大层级
request.SetMaxDepth(2)
//指定业务类型
// request.SetBusinessTypes(&[]string{"1", "2"})
//制定业务
// request.SetBusinessID("YOUR_BUSINESS_ID")
// request.SetClientID("YOUR_CLIENT_ID")
response, err := labelClient.QueryLabel(request)
if err != nil {
// 处理错误并打印日志
log.Fatal(err)
}
if response.GetCode() == 200 {
data := response.Data
fmt.Println("Antispam label size:", len(data))
fmt.Println("Antispam label Name:", *data[0].Name)
fmt.Println("Antispam label code:", *data[0].Label)
fmt.Println("Antispam label subLabel:", *data[0].SubLabels[0].Name)
fmt.Println("Antispam label subLabel code:", *data[0].SubLabels[0].Code)
} else {
fmt.Println("error code: ", response.GetCode())
fmt.Println("error msg: ", response.GetMsg())
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/netease_yidun/yidun-golang-sdk.git
git@gitee.com:netease_yidun/yidun-golang-sdk.git
netease_yidun
yidun-golang-sdk
yidun-golang-sdk
main

Search