PHP Query the method of express information, PHP Express information method
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:
Copy the Code code 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/963829.html www.bkjia.com true http://www.bkjia.com/PHPjc/963829.html techarticle PHP Query Express information method, PHP Express information method in this paper, a sample of the PHP query Express information method. Share to everyone for your reference. Specific as follows: Here use Express 100 things ...