How to query the Express information in PHP
This article mainly introduces the method of PHP query Express information, example analysis of the third-party platform interface to query the courier information skills, with a certain reference value, the need for friends can refer to the next
This paper describes the method of PHP query Express information. Share to everyone for your reference. Specific as follows:
Here use Express 100 Logistics inquiry
HTML-only interfaces in official documents can also return JSON
The PHP code is as follows:
The code is as follows:
/**
* @desc Get Courier Information
* @param string $code Express code
* @param string $invoice Express number
* @return Mixed $result (
' Status ', ' info ', ' state ', ' data '
)
*/
function Getexpressdelivery ($code, $invoice) {
$result = Array (' status ' =>0, ' info ' = ' unknown error ');
$url = "http://m.kuaidi100.com/query?type={$code}&postid={$invoice}&id=1&valicode=&temp=". Rand ( 1,710);
$body = file_get_contents ($url); Fixme
$body = Json_decode ($body, true);
$result [' status '] = $body [' status '] = = 200? 1:0;
$result [' info '] = $body [' message '];
Isset ($body [' Data ') && ($result [' state ']= $body [' State ']) && ($result [' data '] = $body [' data ']);
return $result;
}
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/963969.html www.bkjia.com true http://www.bkjia.com/PHPjc/963969.html techarticle PHP Query The method of express information This article mainly introduces the PHP query Express information method, the example analysis of the third-party platform interface to query the courier information skills, with a certain reference ...