用户之声——提建议·赢好礼> HOT

简介

本文档提供关于网页审核任务的 API 概览和 SDK 示例代码。
注意
旧版本可能存在 bug,使用时建议升级到 最新版本
API
操作描述
用于提交一个网页审核任务。
用于主动查询指定的网页审核任务结果。

提交网页审核任务

功能说明

本接口用于提交一个网页审核任务。网页审核功能为异步任务方式,您可以通过提交网页审核任务审核您的网页文件,然后通过 查询网页审核任务接口网页审核回调 查询审核结果。

方法原型

public Guzzle\\Service\\Resource\\Model detectWebpage(array $args = array());

请求示例

<?php

require dirname(__FILE__, 2) . '/vendor/autoload.php';

$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\\Cos\\Client(
array(
'region' => $region,
'scheme' => 'https', // 审核时必须为https
'credentials' => array(
'secretId' => $secretId,
'secretKey' => $secretKey)));
try {
$result = $cosClient->detectWebpage(array(
'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Input' => array(
'Url' => 'https://www.xxx.com/',
// 'DataId' => 'xxx', // 可选 该字段在审核结果中会返回原始内容,长度限制为512字节。您可以使用该字段对待审核的数据进行唯一业务标识。
// 'UserInfo' => array(
// 'TokenId' => '',
// 'Nickname' => '',
// 'DeviceId' => '',
// 'AppId' => '',
// 'Room' => '',
// 'IP' => '',
// 'Type' => '',
// 'ReceiveTokenId' => '',
// 'Gender' => '',
// 'Level' => '',
// 'Role' => '',
// ), // 可选 用户业务字段
),
// 'Conf' => array(
// 'BizType' => 'd7a51676a0xxxxxxxxxxxxxxxxxxxxxx', // 可选 审核策略
// 'Callback' => 'http://xxx.com/xxx', // 可选 回调地址,以http://或者https://开头的地址。
// 'ReturnHighlightHtml' => 'true', // 可选 true 或者 false 指定是否需要高亮展示网页内的违规文本,查询及回调结果时会根据此参数决定是否返回高亮展示的 html 内容
// ), // 审核规则配置
));
// 请求成功
print_r($result);
} catch (\\Exception $e) {
// 请求失败
echo($e);
}

参数说明

Request 中的具体数据描述如下:
节点名称(关键字)
父节点
描述
类型
是否必选
Input
Request
需要审核的网页信息。
Container
Conf
Request
审核规则配置。
Container
Container 类型 Input 的具体数据描述如下:
节点名称(关键字)
父节点
描述
类型
是否必选
Url
Request.Input
网页文件的链接地址,例如 http://www.test.com
String
DataId
Request.Input
该字段在审核结果中会返回原始内容,长度限制为512字节。您可以使用该字段对待审核的数据进行唯一业务标识。
String
UserInfo
Request.Input
用户业务字段。
Container
Container 节点 UserInfo 的内容:
节点名称(关键字)
父节点
描述
类型
是否必选
TokenId
Request.Input.UserInfo
一般用于表示账号信息,长度不超过128字节。
String
Nickname
Request.Input.UserInfo
一般用于表示昵称信息,长度不超过128字节。
String
DeviceId
Request.Input.UserInfo
一般用于表示设备信息,长度不超过128字节。
String
AppId
Request.Input.UserInfo
一般用于表示 App 的唯一标识,长度不超过128字节。
String
Room
Request.Input.UserInfo
一般用于表示房间号信息,长度不超过128字节。
String
IP
Request.Input.UserInfo
一般用于表示 IP 地址信息,长度不超过128字节。
String
Type
Request.Input.UserInfo
一般用于表示业务类型,长度不超过128字节。
String
ReceiveTokenId
Request.Input.UserInfo
一般用于表示接收消息的用户账号,长度不超过128字节。
String
Gender
Request.Input.UserInfo
一般用于表示性别信息,长度不超过128字节。
String
Level
Request.Input.UserInfo
一般用于表示等级信息,长度不超过128字节。
String
Role
Request.Input.UserInfo
一般用于表示角色信息,长度不超过128字节。
String
Container 类型 Conf 的具体数据描述如下:
节点名称(关键字)
父节点
描述
类型
是否必选
BizType
Request.Conf
表示审核策略的唯一标识,您可以通过控制台上的审核策略页面,配置您希望审核的场景,如涉黄、广告、违法违规等。您可以在控制台上获取到 BizType。BizType 填写时,此条审核请求将按照该审核策略中配置的场景进行审核。BizType 不填写时,将自动使用默认的审核策略。
String
Callback
Request.Conf
回调地址,以http://或者https://开头的地址。
String
ReturnHighlightHtml
Request.Conf
指定是否需要高亮展示网页内的违规文本,查询及回调结果时会根据此参数决定是否返回高亮展示的 html 内容。取值为 true 或者 false,默认为 false。
Boolean

返回结果示例

响应参数含义参考 网页审核API文档
GuzzleHttp\\Command\\Result Object
(
[RequestId] => NjEzYTBjMGVfZmNjYTNiMGFfNGM2Ml8zMTdjYjM=
[ContentType] => application/xml
[ContentLength] => 253312
[JobsDetail] => Array
(
[JobId] => shd61e00d8116f11ec953452540024deb5
[State] => Submitted
[CreationTime] => 2023-05-12T16:13:26+08:00
)

[Key] => shd61e00d8116f11ec953452540024deb5
[Bucket] => examplebucket-1250000000
[Location] => examplebucket-1250000000.ci.ap-guangzhou.myqcloud.com/webpage/auditing
)

查询网页审核任务结果

功能说明

本接口用于主动查询指定的网页审核任务结果。网页审核功能为异步任务方式,您可以通过提交网页审核任务审核您的网页文件,然后通过查询网页审核任务接口查询审核结果。

方法原型

public Guzzle\\Service\\Resource\\Model getDetectWebpageResult(array $args = array());

请求示例

<?php

require dirname(__FILE__, 2) . '/vendor/autoload.php';

$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\\Cos\\Client(
array(
'region' => $region,
'scheme' => 'https', // 审核时必须为https
'credentials'=> array(
'secretId' => $secretId ,
'secretKey' => $secretKey)));
try {
$result = $cosClient->getDetectWebpageResult(array(
'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Key' => '', // jobId
));
// 请求成功
print_r($result);
} catch (\\Exception $e) {
// 请求失败
echo($e);
}

参数说明

Request 中的具体数据描述如下:
参数名称
类型
描述
是否必填
Bucket
String
存储桶名称,格式:BucketName-APPID。
Key
String
需要查询的任务 ID。

返回结果示例

响应参数含义参考 网页审核API文档
GuzzleHttp\\Command\\Result Object
(
[RequestId] => NjEzYTBjMGVfZmNjYTNiMGFfNGM2Ml8zMTdjYjM=
[ContentType] => application/xml
[ContentLength] => 253312
[JobsDetail] => Array
(
[ForbidState] => 0
[JobId] => shd61e00d8116f11ec953452540024deb5
[State] => Success
[CreationTime] => 2023-05-12T16:13:26+08:00
[Url] => https://www.xxx.com/
[Suggestion] => 1
[Label] => Politics
[PageCount] => 39
[Labels] => Array
(
[AbuseInfo] => Array
(
[HitFlag] => 0
[Score] => 0
)

[IllegalInfo] => Array
(
[HitFlag] => 0
[Score] => 0
)

[PornInfo] => Array
(
[HitFlag] => 0
[Score] => 19
)

[AdsInfo] => Array
(
[HitFlag] => 0
[Score] => 0
)

[PoliticsInfo] => Array
(
[HitFlag] => 1
[Score] => 91
)

[TerrorismInfo] => Array
(
[HitFlag] => 0
[Score] => 1
)

)

[ImageResults] => Array
(
[Results] => Array
(
[0] => Array
(
[Url] => https://www.xxx.com/img/xxx/logo/pc/xxx-result.png
[Text] => xxx
[Label] => Normal
[Suggestion] => 0
[PornInfo] => Array
(
[HitFlag] => 0
[Score] => 8
[Category] =>
[SubLabel] =>
)

[AdsInfo] => Array
(
[HitFlag] => 0
[Score] => 0
[Category] =>
[SubLabel] =>
)

[PoliticsInfo] => Array
(
[HitFlag] => 0
[Score] => 0
[Category] =>
[SubLabel] =>
)

[TerrorismInfo] => Array
(
[HitFlag] => 0
[Score] => 1
[Category] =>
[SubLabel] =>
)

)

)

)

[TextResults] => Array
(
[Results] => Array
(
[0] => Array
(
[AbuseInfo] => Array
(
[HitFlag] => 0
[Keywords] => Array
(
)

[Score] => 0
)

[IllegalInfo] => Array
(
[HitFlag] => 0
[Keywords] => Array
(
)

[Score] => 0
)

[Text] => xxx
[Label] => Politics
[Suggestion] => 1
[PornInfo] => Array
(
[HitFlag] => 0
[Score] => 8
[Keywords] =>
)

[AdsInfo] => Array
(
[HitFlag] => 0
[Score] => 0
[Keywords] =>
)

[PoliticsInfo] => Array
(
[HitFlag] => 1
[Score] => 91
[Keywords] => 警xxx独
)

[TerrorismInfo] => Array
(
[HitFlag] => 0
[Score] => 0
[Keywords] =>
)

)

)