How to query express delivery information with PHP_PHP tutorial

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

How to query express delivery information with PHP

This article mainly introduces the method of querying express delivery information with PHP, and analyzes the techniques of querying express delivery information through third-party platform interfaces with examples. For reference value, friends in need can refer to it

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.

www.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...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!