找到前端传过来的文件 获取文件路径名
$img = $request->file('name')->getPathname();
调用图片审核方法
$res = $this->checkImg($img);
返回值是一个数组 可以通过 conclusion 这个下标进行判断是否合规
/**
* 图片审核
*/
public function checkImg($img){
$app_key = "百度智能云key";
$secretkey = "百度智能云服务米有";
$token = $this->getAccessToken($app_key,$secretkey);
$url = 'https://aip.baidubce.com/rest/2.0/solution/v1/img_censor/v2/user_defined?access_token=' . $token;
$img = file_get_contents($img);
$img = base64_encode($img);
$bodys = array(
'image' => $img
);
$res = $this->curlPost($url, $bodys);
$res = json_decode($res,true);
return $res;
}
/**
* 获取百度开放平台的票据
* 参考链接:https://ai.baidu.com/ai-doc/REFERENCE/Ck3dwjhhu
*/
public function getAccessToken(