public function img()
{
$url = 'http://ai.qiniuapi.com/v3/image/censor';
$method = "POST";//
$host = "ai.qiniuapi.com";
$contentType = "application/json";
$image = "https://img-home.csdnimg.cn/images/20211130015710.jpg";//图片链接
$scenes = [
'censor' => ['pulp', 'terror', 'politician', 'ads'],
'pulp' => ['pulp'],
'terror' => ['terror'],
'politician' => ['politician'],
'ads' => ['ads']
];
$body = [
'data' => ['uri' => $image],
'params' => ['scenes' => $scenes['censor']]
];
$auth = new Auth('wiy4kLzOdWWSqhmRPHK-b2fVcyChFNYHBmU2hb6r', '6-WExhU5oseAlrVecLWwBtjCNitrsK3OeHwgRswq');
$headers = $auth->authorizationV2($url, $method, json_encode($body), $contentType);
$headers['Content-Type'] = $contentType;
$headers['Host'] = $host;
$response = \Qiniu\Http\Client::post($url, json_encode($body), $headers);
//拿到$response返回值,返回所需要的数据
print_r($response);
}
|