PHP Query Express Information Method _php Tutorial

Source: Internet
Author: User

How to query the Express information in PHP


This article mainly introduces the method of PHP query Express information, example analysis of the third-party platform interface to query the courier information skills, with a certain reference value, the need for friends can refer to the next

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:

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 is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/963969.html www.bkjia.com true http://www.bkjia.com/PHPjc/963969.html techarticle PHP Query The method of express information This article mainly introduces the PHP query Express information method, the example analysis of the third-party platform interface to query the courier information skills, with a certain reference ...

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