ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ <?php /* * 如有疑问可与技术联系QQ:706448591 */ $url = "http://shenfenzhe.market.alicloudapi.com/do";//支持https 如需https请修改 $method = "1";//post=1 get=0 $appcode = "你的appcode"; $data = array( 'image'=>'http://storage.api51.cn/demo/zheng.jpg',//身份证图片远程地址(确保可以访问) 'id_card_side'=>'front',//身份证正反面参数, 正面 front 反面 back ); $data = http_build_query($data); $result = api51_curl($url,$data,$method,$appcode); echo $result; function api51_curl($url,$data=false,$ispost=0,$appcode){ $headers = array(); //根据阿里云要求,定义Appcode array_push($headers, "Authorization:APPCODE " . $appcode); array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8"); $httpInfo = array(); $ch = curl_init(); curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 ); curl_setopt( $ch, CURLOPT_USERAGENT , 'api51.cn' ); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 300 ); curl_setopt( $ch, CURLOPT_TIMEOUT , 300); curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true ); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FAILONERROR, false); if (1 == strpos("$".$url, "https://")) { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); } if($ispost) { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt( $ch , CURLOPT_POST , true ); curl_setopt( $ch , CURLOPT_POSTFIELDS , $data ); curl_setopt( $ch , CURLOPT_URL , $url ); } else { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); if($data){ curl_setopt( $ch , CURLOPT_URL , $url.'?'.$data ); }else{ curl_setopt( $ch , CURLOPT_URL , $url); } } $response = curl_exec( $ch ); if ($response === FALSE) { // echo "cURL Error: " . curl_error($ch); return false; } $httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE ); $httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) ); curl_close( $ch ); return $response; } ?> ~~~