function get_business_info($img_path,$appcode){ //識別營業(yè)執(zhí)照圖片
$r=array('state'=>'fail','msg'=>'圖片不存在',);
if(!is_file($img_path)){return $r;}
$info=getimagesize($img_path);
if($info[0]>$info[1]){$type='buslicense';}else{$type='businesslicense';}
//var_dump($type);
//$type='businesslicense 豎 or buslicense 橫';
$host = "https://bnesslic.market.alicloudapi.com";
? ? $path = "/".$type;
? ? $method = "POST";
? ? $headers = array();
? ? array_push($headers, "Authorization:APPCODE " . $appcode);
? ? //根據(jù)API的要求,定義相對應(yīng)的Content-Type
? ? array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8");
? ? $querys = "";
$bodys = 'image='.imgToBase64($img_path).'';
? ? $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);
? ? curl_setopt($curl, CURLOPT_HEADER, true);
? ? 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);
? ? $out_put = curl_exec($curl);
$t=explode('{"code"', $out_put);
? ? $v='{"code"'.$t[1];
$r=json_decode($v,1);
if($r['code']!=1){$r['state']='fail';return $r;}
if(isset($r['result']['社會信用代碼']['words']) && $r['result']['社會信用代碼']['words']!='無'){$r['result']['統(tǒng)一社會信用代碼']['words']=$r['result']['社會信用代碼']['words'];}
if(isset($r['result']['證件編號']['words']) && $r['result']['證件編號']['words']!='無'){$r['result']['統(tǒng)一社會信用代碼']['words']=$r['result']['證件編號']['words'];}
if(!isset($r['result']['統(tǒng)一社會信用代碼'])){$r['state']='fail';return $r;}
if(@$r['result']['統(tǒng)一社會信用代碼']['words']=='' || @$r['result']['統(tǒng)一社會信用代碼']['words']=='無'){$r['state']='fail';return $r;}
$msg=$r['msg'];
$r=$r['result'];
$r=format_business_info($r);
$r['state']='success';
$r['msg']=$msg;
return $r;