Home > Backend Development > PHP Tutorial > How to query courier information in PHP, how to query courier information in PHP_PHP tutorial

How to query courier information in PHP, how to query courier information in PHP_PHP tutorial

WBOY
Release: 2016-07-13 10:05:29
Original
1124 people have browsed it

How to query courier information with PHP, PHP courier information method

The example in this article describes the method of querying courier 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:

Copy code 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 will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/963829.htmlTechArticleHow to query express delivery information with PHP, PHP express delivery information method This article describes the method of querying express delivery information with PHP. Share it with everyone for your reference. The details are as follows: Use express delivery for 100 items here...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template