The example in this article describes how to query express delivery information with PHP. Share it with everyone for your reference. The details are as follows:
Use Express 100 logistics inquiry here
The official document can only return html interface, but 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 delivery 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 will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/963969.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/963969.htmlTechArticleHow to Query Express Information with PHP This article mainly introduces the method of querying express information with PHP. The example analyzes The techniques for querying express delivery information through third-party platform interfaces have certain reference points...