Skip to content

Commit afc332f

Browse files
authored
auditing params (#246)
1 parent 899cf89 commit afc332f

12 files changed

+1721
-351
lines changed

sample/detectAudio.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
),
2222
'Conf' => array(
2323
'DetectType' => 'Porn,Terrorism,Politics,Ads',
24-
'Callback' => 'https://example.com/callback',
25-
'BizType' => '',
24+
// 'Callback' => 'https://example.com/callback',
25+
// 'CallbackVersion' => '',
26+
// 'BizType' => '',
2627
),
2728
));
2829
// 请求成功
@@ -37,8 +38,9 @@
3738
),
3839
'Conf' => array(
3940
'DetectType' => 'Porn,Terrorism,Politics,Ads',
40-
'Callback' => 'https://example.com/callback',
41-
'BizType' => '',
41+
// 'Callback' => 'https://example.com/callback',
42+
// 'CallbackVersion' => '',
43+
// 'BizType' => '',
4244
),
4345
));
4446
// 请求成功

sample/detectDocument.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,31 @@
1313
'secretId' => $secretId ,
1414
'secretKey' => $secretKey)));
1515
try {
16+
// 存储桶文档审核
17+
$result = $cosClient->detectDocument(array(
18+
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
19+
'Input' => array(
20+
'Object' => 'test01.docx',
21+
// 'Type' => 'docx',
22+
),
23+
'Conf' => array(
24+
'DetectType' => 'Porn,Terrorism,Politics,Ads',
25+
// 'Callback' => 'https://example.com/callback/',
26+
// 'BizType' => '',
27+
),
28+
));
29+
30+
// 文档URL审核
1631
$result = $cosClient->detectDocument(array(
1732
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
1833
'Input' => array(
1934
'Url' => 'https://example.com/test01.docx',
20-
'Type' => 'docx',
35+
// 'Type' => 'docx',
2136
),
2237
'Conf' => array(
2338
'DetectType' => 'Porn,Terrorism,Politics,Ads',
24-
'Callback' => 'https://example.com/callback/',
25-
'BizType' => '',
39+
// 'Callback' => 'https://example.com/callback/',
40+
// 'BizType' => '',
2641
),
2742
));
2843
// 请求成功

sample/detectImage.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
require dirname(__FILE__) . '/../vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
6+
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
7+
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
8+
$cosClient = new Qcloud\Cos\Client(
9+
array(
10+
'region' => $region,
11+
'schema' => 'https', //协议头部,默认为http
12+
'credentials' => array(
13+
'secretId' => $secretId,
14+
'secretKey' => $secretKey)));
15+
try {
16+
//存储桶图片审核
17+
$result = $cosClient->detectImage(array(
18+
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
19+
'Key' => 'exampleobject',
20+
'DetectType' => 'porn,politics', //可选四种参数:porn,politics,terrorist,ads,可使用多种规则,注意规则间不要加空格
21+
'ci-process' => 'sensitive-content-recognition',
22+
// 'Interval' => 5, // 审核gif时使用 截帧的间隔
23+
// 'MaxFrames' => 5, // 针对 GIF 动图审核的最大截帧数量,需大于0。
24+
// 'BizType' => '', // 审核策略
25+
));
26+
// 请求成功
27+
print_r($result);
28+
29+
30+
//图片链接审核
31+
$imgUrl = 'https://test.jpg';
32+
$result = $cosClient->detectImage(array(
33+
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
34+
'Key' => '/', // 链接图片资源路径写 / 即可
35+
'DetectType' => 'porn,ads',//可选四种参数:porn,politics,terrorist,ads,可使用多种规则,注意规则间不要加空格
36+
'DetectUrl' => $imgUrl,
37+
'ci-process' => 'sensitive-content-recognition',
38+
// 'Interval' => 5, // 审核gif时使用 截帧的间隔
39+
// 'MaxFrames' => 5, // 针对 GIF 动图审核的最大截帧数量,需大于0。
40+
// 'BizType' => '', // 审核策略
41+
));
42+
// 请求成功
43+
print_r($result);
44+
} catch (\Exception $e) {
45+
// 请求失败
46+
echo($e);
47+
}
48+

sample/detectImages.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
require dirname(__FILE__) . '/../vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
6+
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
7+
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
8+
$cosClient = new Qcloud\Cos\Client(
9+
array(
10+
'region' => $region,
11+
'schema' => 'https', //协议头部,默认为http
12+
'credentials' => array(
13+
'secretId' => $secretId,
14+
'secretKey' => $secretKey)));
15+
try {
16+
$imgUrl = 'http://example.com/test.php';
17+
$result = $cosClient->detectImages(array(
18+
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
19+
'Inputs' => array(
20+
array(
21+
'Object' => 'test01.png',
22+
// 'Interval' => '',
23+
// 'MaxFrames' => '',
24+
// 'DataId' => 'aaa',
25+
),
26+
array(
27+
'Url' => $imgUrl,
28+
// 'Interval' => '',
29+
// 'MaxFrames' => '',
30+
// 'DataId' => 'bbb',
31+
),
32+
),
33+
'Conf' => array(
34+
'DetectType' => 'Porn,Terrorism,Politics,Ads',
35+
// 'BizType' => ''
36+
)
37+
));
38+
// 请求成功
39+
print_r($result);
40+
} catch (\Exception $e) {
41+
// 请求失败
42+
echo($e);
43+
}
44+

sample/detectText.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
),
3838
'Conf' => array(
3939
'DetectType' => 'Porn,Terrorism,Politics,Ads',
40-
'Callback' => 'https://example.callback.com/test/', // 回调URL
41-
'BizType' => '',
40+
// 'Callback' => 'https://example.callback.com/test/', // 回调URL
41+
// 'CallbackVersion' => 'Detail',
42+
// 'BizType' => '',
4243
),
4344
));
4445
// 请求成功

sample/detectVideo.php

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,47 @@
1313
'secretId' => $secretId ,
1414
'secretKey' => $secretKey)));
1515
try {
16+
//存储桶视频审核
1617
$result = $cosClient->detectVideo(array(
1718
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
1819
'Input' => array(
19-
'Object' => 'video01.mp4',
20+
'Object' => 'test.mp4', // 存储桶文件
2021
),
2122
'Conf' => array(
2223
'DetectType' => 'Porn,Terrorism,Politics,Ads',
23-
'Callback' => 'https://example.com/callback',
24-
'BizType' => '',
25-
'DetectContent' => 1,
26-
'CallbackVersion' => 'Detail',
24+
// 'Callback' => 'https://example.com/callback',
25+
// 'BizType' => '',
26+
// 'DetectContent' => 1,
27+
// 'CallbackVersion' => 'Detail',
2728
'Snapshot' => array(
28-
'Mode' => 'Interval',
29-
'TimeInterval' => 50,
30-
'Count' => '100',
29+
// 'Mode' => 'Average',
30+
// 'TimeInterval' => 50,
31+
'Count' => '3',
3132
),
3233
),
3334
));
35+
36+
//视频url审核
37+
$videoUrl = 'http://example.com/test.mp4';
38+
$result = $cosClient->detectVideo(array(
39+
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
40+
'Input' => array(
41+
'Url' => $videoUrl, // 视频url
42+
),
43+
'Conf' => array(
44+
'DetectType' => 'Porn,Terrorism,Politics,Ads',
45+
// 'Callback' => 'https://example.com/callback',
46+
// 'BizType' => '',
47+
// 'DetectContent' => 1,
48+
// 'CallbackVersion' => 'Detail',
49+
'Snapshot' => array(
50+
// 'Mode' => 'Average',
51+
// 'TimeInterval' => 50,
52+
'Count' => '3',
53+
),
54+
),
55+
));
56+
3457
// 请求成功
3558
print_r($result);
3659
} catch (\Exception $e) {

sample/getObjectSensitiveContentRecognition.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
'secretId' => $secretId,
1414
'secretKey' => $secretKey)));
1515
try {
16+
/**
17+
* 此接口已不再维护 2021.11.25
18+
* 图片审核建议使用 detectImage & detectImages 两个接口
19+
* 新增功能字段会在 detectImage & detectImages 接口维护
20+
*/
1621
//存储桶图片审核
1722
$result = $cosClient->getObjectSensitiveContentRecognition(array(
1823
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket

src/Client.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@
109109
* @method object DescribeDocProcessQueues(array $args) 提交文档转码任务
110110
* @method object DescribeDocProcessJob(array $args) 查询文档转码队列
111111
* @method object GetDescribeDocProcessJobs(array $args) 查询文档转码任务
112+
* @method object DetectImage(array $args) 图片审核
113+
* @method object DetectImages(array $args) 图片审核-批量
112114
* @see \Qcloud\Cos\Service::getService()
113115
*/
114116
class Client extends GuzzleClient {

src/CommandToRequestTransformer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ public function cosDomain2CiTransformer(CommandInterface $command, $request) {
234234
'DescribeDocProcessQueues' => 1,
235235
'DescribeDocProcessJob' => 1,
236236
'GetDescribeDocProcessJobs' => 1,
237+
'DetectImages' => 1,
237238
);
238239
if (key_exists($action, $ciActions)) {
239240
$bucketname = $command['Bucket'];

0 commit comments

Comments
 (0)