如何实时查询快递API.PHP的详细步骤?
- 内容介绍
- 文章标签
- 相关推荐
本文共计251个文字,预计阅读时间需要2分钟。
使用快递查询API进行实时查询,输入参数如下:API.php + 'LK664578623CN','carrier_code'='china-ems'。调用curl_post函数发送POST请求,输出查询结果。
快递实时查询API.PHP'LK664578623CN', 'carrier_code'=>'china-ems' ); $res = curl_post($url,json_encode($postData),$header); print_r($res); function curl_post($url, $postData,$header=array(),$cookie_file='',$isheader=0,$proxy='',$debug=0,$autoRedirect=0,$time=89){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if(!empty($isheader)){ curl_setopt($ch, CURLOPT_HEADER, $isheader); } curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT,$time); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:44.0) Gecko/20100101 Firefox/44.0'); if(!empty($header)){ curl_setopt($ch, CURLOPT_HTTPHEADER,$header); } if(!empty($autoRedirect)){ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); } if(!empty($cookie_file)){ // 读取文件所储存的Cookie信息 curl_setopt ( $ch, CURLOPT_COOKIEFILE, $cookie_file ); } if(!empty($proxy)){ curl_setopt($ch, CURLOPT_PROXY, $proxy); } //curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate'); if(!empty($debug)){ curl_setopt($ch,CURLOPT_VERBOSE,1); curl_setopt($ch,CURLOPT_FAILONERROR,TRUE); print_r(curl_error($ch)); print_r(curl_getinfo($ch)); } $html = curl_exec($ch); curl_close($ch); return $html; }
本文共计251个文字,预计阅读时间需要2分钟。
使用快递查询API进行实时查询,输入参数如下:API.php + 'LK664578623CN','carrier_code'='china-ems'。调用curl_post函数发送POST请求,输出查询结果。
快递实时查询API.PHP'LK664578623CN', 'carrier_code'=>'china-ems' ); $res = curl_post($url,json_encode($postData),$header); print_r($res); function curl_post($url, $postData,$header=array(),$cookie_file='',$isheader=0,$proxy='',$debug=0,$autoRedirect=0,$time=89){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if(!empty($isheader)){ curl_setopt($ch, CURLOPT_HEADER, $isheader); } curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT,$time); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:44.0) Gecko/20100101 Firefox/44.0'); if(!empty($header)){ curl_setopt($ch, CURLOPT_HTTPHEADER,$header); } if(!empty($autoRedirect)){ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); } if(!empty($cookie_file)){ // 读取文件所储存的Cookie信息 curl_setopt ( $ch, CURLOPT_COOKIEFILE, $cookie_file ); } if(!empty($proxy)){ curl_setopt($ch, CURLOPT_PROXY, $proxy); } //curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate'); if(!empty($debug)){ curl_setopt($ch,CURLOPT_VERBOSE,1); curl_setopt($ch,CURLOPT_FAILONERROR,TRUE); print_r(curl_error($ch)); print_r(curl_getinfo($ch)); } $html = curl_exec($ch); curl_close($ch); return $html; }

