How to query express information by PHP
This article will explain in detail how to query express information about PHP. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
The details are as follows:
Express 100 logistics query is used here.
An API that can only return html in official documents can also return json.
The php code is as follows:
/ * @ desc to get express information * @ param string $code express code * @ param string $invoice express order number * @ return mixed $result ('status','info','state','data') * / function getExpressDelivery ($code,$invoice) {$result = array (' status'= > 0charge infotainment = > '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 } this is the end of the article on "how to query express information on PHP". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.