PHP query Express information method, PHP Express information Method _php Tutorial

Source: Internet
Author: User

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.