PHP 七牛云图片审核
https://developer.qiniu.com/censor/api/5588/i
composer 安装 七牛云sdk
php composer.phar require qiniu/php-sdk
argvs 参考官方文档
方法调用
function getPicCensor($image_url='', $scene='censor', $method='POST')
{
$auth = new Auth('AccessKey','SecretKey');
$uri = 'http://ai.qiniuapi.com/v3/image/censor';
$contentType = 'application/json';
$scenes = [
'censor' => ['pulp', 'terror', 'politician', 'ads'],
'pulp' => ['pulp'],
'terror' => ['terror'],
'politician' => ['politician'],
'ads' => ['ads']
];
$body = [
'data' => ['uri' => $image_url],
'params' => ['scenes' => $scenes[$scene]]
];
// 拦截违规图片级别
$suggestions = [
// 'pass' => 'pass', // 通过
// 'review' => 'review', // 疑似
'block' => 'block' // 违规
];
$sign = $auth->authorizationV2($uri, $method, json_encode($body), $contentType);
$header = ['Content-Type: '. $contentType, 'Authorization: '.$sign['Authorization']];
$res = http_request($uri, json_encode($body), $header);
// result
$res = json_decode($res, true);
print_r($res);
}