有奖捉虫:云通信与企业服务文档专题,速来> HOT

简介

内容审核功能是由 数据万象(Cloud Infinite,CI)提供的,数据万象将处理能力与 COS SDK 完全结合,您可以直接按照本篇文档指引进行使用。
说明
使用内容审核服务需拥有数据万象使用权限:
主账号请 单击此处 进行角色授权。
子账号请参见 授权子账号接入数据万象服务 文档。
本文档提供关于网页审核的 API 概览和 SDK 示例代码。
API
操作描述
用于提交一个网页审核任务
用于查询指定的网页审核任务

创建任务

PutWebpageAuditingJob 接口用于提交一个网页审核任务。您可以通过主动设置回调地址接收审核信息,也可以通过 JobId 进行查询。

方法原型

func (s *CIService) PutWebpageAuditingJob(ctx context.Context, opt *PutWebpageAuditingJobOptions) (*PutWebpageAuditingJobResult, *Response, error)

请求示例

// 将 examplebucket-1250000000 和 COS_REGION 修改为真实的信息
// CI 任务需要提供CIURL
bu, _ := url.Parse("https://examplebucket-1250000000.cos.COS_REGION.myqcloud.com")
cu, _ := url.Parse("https://examplebucket-1250000000.ci.COS_REGION.myqcloud.com")
b := &cos.BaseURL{BucketURL: bu, CIURL: cu}
c := cos.NewClient(b, &http.Client{
Transport: &cos.AuthorizationTransport{
SecretID: os.Getenv("SECRETID"),
SecretKey: os.Getenv("SECRETKEY"),
}
})
opt := &cos.PutWebpageAuditingJobOptions{
InputUrl: "http://www.test.com",
Conf: &cos.WebpageAuditingJobConf{
},
}
res, _, err := c.CI.PutWebpageAuditingJob(context.Background(), opt)

参数说明

type PutWebpageAuditingJobOptions struct {
InputUrl string
InputDataId string
InputUserInfo *UserExtraInfo
Conf *WebpageAuditingJobConf
}
type UserExtraInfo struct {
TokenId string
Nickname string
DeviceId string
AppId string
Room string
IP string
Type string
}
type WebpageAuditingJobConf struct {
Callback string
ReturnHighlightHtml bool
}

参数名称
参数描述
类型
是否必填
InputUrl
网页文件的链接地址,例如 http://www.test.com
String
InputDataId
网页标识,该字段在结果中返回原始内容,长度限制为512字节。
String
InputUserInfo
用户业务字段。
Object
Conf
审核规则配置。
Struct
Callback
回调地址,以 http:// 或者 https:// 开头的地址。
String
ReturnHighlightHtml
指定是否需要高亮展示网页内的违规文本,并返回高亮展示的 html 链接。取值为 true 和 false,默认为 false。
Bool

结果说明

调用 PutWebpageAuditingJob 函数,会解析 API 返回的 xml 内容到 PutWebpageAuditingJobResult 结构,具体返回参数可查看 提交网页审核任务 文档。

查询任务

GetWebpageAuditingJob 接口用于查询指定的网页审核任务。您可以根据网页审核任务的 JobId 来查询网页审核结果。

方法原型

func (s *CIService) GetWebpageAuditingJob(ctx context.Context, jobid string) (*GetWebpageAuditingJobResult, *Response, error)

请求示例

// 将 examplebucket-1250000000 和 COS_REGION 修改为真实的信息
// CI 任务需要提供 CIURL
bu, _ := url.Parse("https://examplebucket-1250000000.cos.COS_REGION.myqcloud.com")
cu, _ := url.Parse("https://examplebucket-1250000000.ci.COS_REGION.myqcloud.com")
b := &cos.BaseURL{BucketURL: bu, CIURL: cu}
c := cos.NewClient(b, &http.Client{
Transport: &cos.AuthorizationTransport{
SecretID: os.Getenv("SECRETID"),
SecretKey: os.Getenv("SECRETKEY"),
}
})
jobId := "shce25f391a72e11eb99f********"
res, _, err := c.CI.GetWebpageAuditingJob(context.Background(), jobId)

参数说明

参数名称
参数描述
类型
jobId
任务 ID。
String

结果说明

调用 GetWebpageAuditingJob 函数,会解析 API 返回的 xml 内容到 GetWebpageAuditingJobResult 结构,具体返回参数可查看 查询网页审核任务结果 文档。