PHP method of querying express information, PHP method of express information _ PHP Tutorial

Source: Internet
Author: User
The PHP method for querying express information, and the PHP method for querying express information. The PHP method for querying express information. the PHP method for querying express information is described in this article. Share it with you for your reference. The details are as follows: Here, we use PHP to query the express delivery information, and PHP to express the information.

This article describes how to query the express delivery information in PHP. Share it with you for your reference. The details are as follows:

Here we use express 100 for logistics query
Only html interfaces or json interfaces can be returned in the official documentation.

The php code is as follows:

The code is as follows :/**
* @ Desc get the express delivery information
* @ Param string $ code Express code
* @ Param string $ invoice express Bill No.
* @ 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 help you with php programming.

The example in this article describes how to query the express delivery information in PHP. Share it with you for your reference. The details are as follows: Here we use express delivery 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.