Skip to content

Commit b73afff

Browse files
authored
内容审核:语音、视频、文本、文档 (#219)
1 parent 4a3d136 commit b73afff

12 files changed

+710
-3
lines changed

sample/detectAudio.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
require dirname(__FILE__) . '/../vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
6+
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
7+
$region = "ap-beijing"; //设置一个默认的存储桶地域
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+
$result = $cosClient->detectAudio(array(
17+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
18+
'Input' => array(
19+
'Object' => 'sound01.mp3',
20+
),
21+
'Conf' => array(
22+
'DetectType' => 'Porn,Terrorism,Politics,Ads',
23+
'Callback' => 'https://example.com/callback',
24+
'BizType' => '',
25+
),
26+
));
27+
// 请求成功
28+
print_r($result);
29+
} catch (\Exception $e) {
30+
// 请求失败
31+
echo($e);
32+
}
33+

sample/detectDocument.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
require dirname(__FILE__) . '/../vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
6+
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
7+
$region = "ap-beijing"; //设置一个默认的存储桶地域
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+
$result = $cosClient->detectAudio(array(
17+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
18+
'Input' => array(
19+
'Url' => 'https://example.com/test01.docx',
20+
'Type' => 'docx',
21+
),
22+
'Conf' => array(
23+
'DetectType' => 'Porn,Terrorism,Politics,Ads',
24+
'Callback' => 'https://example.com/callback/',
25+
'BizType' => '',
26+
),
27+
));
28+
// 请求成功
29+
print_r($result);
30+
} catch (\Exception $e) {
31+
// 请求失败
32+
echo($e);
33+
}
34+

sample/detectVideo.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
require dirname(__FILE__) . '/../vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
6+
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
7+
$region = "ap-beijing"; //设置一个默认的存储桶地域
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+
$result = $cosClient->detectVideo(array(
17+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
18+
'Input' => array(
19+
'Object' => 'video01.mp4',
20+
),
21+
'Conf' => array(
22+
'DetectType' => 'Porn,Terrorism,Politics,Ads',
23+
'Callback' => 'https://example.com/callback',
24+
'BizType' => '',
25+
'DetectContent' => 1,
26+
'CallbackVersion' => 'Detail',
27+
'Snapshot' => array(
28+
'Mode' => 'Interval',
29+
'TimeInterval' => 50,
30+
'Count' => '100',
31+
),
32+
),
33+
));
34+
// 请求成功
35+
print_r($result);
36+
} catch (\Exception $e) {
37+
// 请求失败
38+
echo($e);
39+
}
40+

sample/getDetectAudioResult.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
require dirname(__FILE__) . '/../vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
6+
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
7+
$region = "ap-beijing"; //设置一个默认的存储桶地域
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+
$result = $cosClient->getDetectAudioResult(array(
17+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
18+
'Key' => 'exampleobject', // jobId
19+
));
20+
// 请求成功
21+
print_r($result);
22+
} catch (\Exception $e) {
23+
// 请求失败
24+
echo($e);
25+
}
26+

sample/getDetectDocumentResult.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
require dirname(__FILE__) . '/../vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
6+
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
7+
$region = "ap-beijing"; //设置一个默认的存储桶地域
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+
$result = $cosClient->getDetectDocumentResult(array(
17+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
18+
'Key' => 'exampleobject', // jobId
19+
));
20+
// 请求成功
21+
print_r($result);
22+
} catch (\Exception $e) {
23+
// 请求失败
24+
echo($e);
25+
}
26+

sample/getDetectTextResult.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
require dirname(__FILE__) . '/../vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
6+
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
7+
$region = "ap-beijing"; //设置一个默认的存储桶地域
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+
$result = $cosClient->getDetectTextResult(array(
17+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
18+
'Key' => 'exampleobject', // jobId
19+
));
20+
// 请求成功
21+
print_r($result);
22+
} catch (\Exception $e) {
23+
// 请求失败
24+
echo($e);
25+
}
26+

sample/getDetectVideoResult.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
require dirname(__FILE__) . '/../vendor/autoload.php';
4+
5+
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
6+
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
7+
$region = "ap-beijing"; //设置一个默认的存储桶地域
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+
$result = $cosClient->getDetectVideoResult(array(
17+
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
18+
'Key' => 'exampleobject', // jobId
19+
));
20+
// 请求成功
21+
print_r($result);
22+
} catch (\Exception $e) {
23+
// 请求失败
24+
echo($e);
25+
}
26+

src/Qcloud/Cos/Client.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,14 @@
9292
* @method object DeleteBucketGuetzli (array $arg)
9393
* @method object GetObjectSensitiveContentRecognition (array $arg)
9494
* @method object DetectText (array $arg)
95+
* @method object GetDetectTextResult (array $arg)
9596
* @method object CreateMediaTranscodeJobs (array $arg)
97+
* @method object DetectAudio (array $arg)
98+
* @method object GetDetectAudioResult (array $arg)
99+
* @method object DetectVideo (array $arg)
100+
* @method object GetDetectVideoResult (array $arg)
101+
* @method object DetectDocument (array $arg)
102+
* @method object GetDetectDocumentResult (array $arg)
96103
*/
97104
class Client extends GuzzleClient {
98105
const VERSION = '2.3.0';

src/Qcloud/Cos/CommandToRequestTransformer.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,18 @@ public function ciParamTransformer( CommandInterface $command, $request ) {
218218

219219
public function cosDomain2CiTransformer($command, $request) {
220220
$action = $command->getName();
221-
if ($action == 'DetectText' || $action == 'CreateMediaTranscodeJobs') {
221+
$ciActions = array(
222+
'DetectText' => 1,
223+
'CreateMediaTranscodeJobs' => 1,
224+
'DetectAudio' => 1,
225+
'GetDetectAudioResult' => 1,
226+
'GetDetectTextResult' => 1,
227+
'DetectVideo' => 1,
228+
'GetDetectVideoResult' => 1,
229+
'DetectDocument' => 1,
230+
'GetDetectDocumentResult' => 1,
231+
);
232+
if (key_exists($action, $ciActions)) {
222233
$bucketname = $command['Bucket'];
223234
$appId = $this->config['appId'];
224235
if ( $appId != null && endWith( $bucketname, '-'.$appId ) == False ) {

0 commit comments

Comments
 (0)