七牛云图片审核

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);
}

mage-censor

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值