im/vendor/qiniu/php-sdk/examples/censor_image.php

43 lines
912 B
PHP
Raw Permalink Normal View History

2023-09-26 18:09:46 +08:00
<?php
require_once __DIR__ . '/../autoload.php';
use Qiniu\Auth;
use Qiniu\Config;
use Qiniu\Storage\ArgusManager;
// 控制台获取密钥https://portal.qiniu.com/user/key
$accessKey = getenv('QINIU_ACCESS_KEY');
$secretKey = getenv('QINIU_SECRET_KEY');
$auth = new Auth($accessKey, $secretKey);
$config = new Config();
$argusManager = new ArgusManager($auth, $config);
// 图片内容审核
// 参考文档https://developer.qiniu.com/censor/api/5588/image-censor
$body = '{
"data":{
"uri":"https://www-static.qbox.me/_next/static/media/pic01.c8b5db2cc5fcb6fc4e6349c9e37c8e6b.png"
},
"params":{
"scenes":[
"pulp",
"terror",
"politician",
"ads"
]
}
}';
list($ret, $err) = $argusManager->censorImage($body);
echo "\n====> Result is: \n";
if ($err !== null) {
var_dump($err);
} else {
var_dump($ret);
}