简介
本文档提供关于网页审核的 API 概览和 SDK 示例代码。
创建任务
PutWebpageAuditingJob 接口用于提交一个网页审核任务。您可以通过主动设置回调地址接收审核信息,也可以通过 JobId 进行查询。
方法原型
func (s *CIService) PutWebpageAuditingJob(ctx context.Context, opt *PutWebpageAuditingJobOptions) (*PutWebpageAuditingJobResult, *Response, error)
请求示例
// 将 examplebucket-1250000000 和 COS_REGION 修改为真实的信息// CI 任务需要提供 CIURLbu, _ := 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 stringInputDataId stringInputUserInfo *UserExtraInfoConf *WebpageAuditingJobConf}type UserExtraInfo struct {TokenId stringNickname stringDeviceId stringAppId stringRoom stringIP stringType string}type WebpageAuditingJobConf struct {Callback stringReturnHighlightHtml 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 任务需要提供 CIURLbu, _ := 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 结构,具体返回参数可查看 查询网页审核任务结果 文档。