public function ALiSlyface() { $host = "https://slyface.market.alicloudapi.com"; $path = "/post/faceidcard/compare"; $method = "POST"; $appcode = "你的code"; $headers = array(); array_push($headers, "Authorization:APPCODE " . $appcode); array_push($headers, "Content-Type" . ":" . "application/x-www-form-urlencoded; charset=UTF-8"); $url = Request::param('link'); $name = Request::param('name'); $idcard = Request::param('idcard'); $image = urlencode($url); $bodys = "idcard=$idcard&name=" . urlencode($name) . "&url=" . $image; $url = $host . $path; $curl = curl_init(); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //设定返回信息中是否包含响应信息头,启用时会将头文件的信息作为数据流输出,true 表示输出信息头, false表示不输出信息头 //如果需要将字符串转成json,请将 CURLOPT_HEADER 设置成 false curl_setopt($curl, CURLOPT_HEADER, false); if (1 == strpos("$" . $host, "https://")) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); } curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys); $res = json_decode(curl_exec($curl), true); if($res['success'] == true ) { return success(Status::SUCCESS, '操作成功', [ "data" => $res ]); }else{ return error(Status::ERROR, '', [ "data" => $res ]); } }
标签:false,setopt,url,阿里,人脸,身份证,curl,CURLOPT,name From: https://www.cnblogs.com/G921123/p/17806043.html