🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ <?php // +---------------------------------------------------------------------- //wangjikeji.com // 快递数据数据调用示例代码 - 网极科技 error_reporting(0); header('Content-Type: text/html; charset=UTF-8'); $url = "http://express.api51.cn/query?postid=402479420842&temp=123456&type=shunfeng";//请求地址 /* postid:快递单号 type:快递公司拼音简写 */ $content = wangji_curl($url); echo $content; function wangji_curl($url,$params=false,$ispost=0){ $httpInfo = array(); $ch = curl_init(); $appcode = "****";//购买后可获得 购买后在阿里云控制台 云市场 查看 $headers = array(); array_push($headers, "Authorization:APPCODE " . $appcode); curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 ); curl_setopt( $ch, CURLOPT_USERAGENT , 'JuheData' ); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 ); curl_setopt( $ch, CURLOPT_TIMEOUT , 60); curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true ); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); if( $ispost ) { curl_setopt( $ch , CURLOPT_POST , true ); curl_setopt( $ch , CURLOPT_POSTFIELDS , $params ); curl_setopt( $ch , CURLOPT_URL , $url ); } else { if($params){ curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params ); }else{ curl_setopt( $ch , CURLOPT_URL , $url); } curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } $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; } ~~~