Express Query API interface PHP source code program

Source: Internet
Author: User
PHP-based development of the Express Query API interface, can be directly integrated use, interface platform: Express network.

Support format: Json/xml, support more than 300 domestic and foreign courier and Logistics company's Express tracking number query, such as: four-way, Shun Fung, every day, EMS and other (domestic) TNT, DHL, UPS and other (foreign), development interface stability. Can be used for interested learning and communication.

1.kuadidiapi.php

 _appkey = $key; }/** * Sets the data return type. 0: Returns the JSON string;    1: Return XML Object * @param number $show */Public Function setshow ($show = 0) {$this->_show = $show; }/** * Sets the number of returned logistics information entries, 0: Returns multiple lines of complete information;    1: Return only one line of information * @param number $muti */Public Function Setmuti ($muti = 0) {$this->_muti = $muti; }/** * Set the return logistics information sort. Desc: Arranged by time from new to old; ASC: Sort by time from old to new * @param string $order */Public Function setorder ($order = ' desc ') {$this->_order = $o    Rder; }/** * Inquiry Logistics information, incoming ticket number, * @param logistics number $NU * @param company code $com to inquire about The courier company codes, do not support Chinese, please refer to the courier company code documents. Do not fill the default according to the number of automatic matching company.     Note: The number matching success rate is higher than 95%. * @throws Exception * @return Array */Public Function query ($nu, $com = ") {if (Function_exists (' curl_in            it ') = = 1) {$url = $this->_apiurl; $DATAARR = array (' id ' = = $this->_appkey, ' com ' + = $com, ' nu ' = = $nu, ' Show' = = $this->_show, ' muti ' and ' $this->_muti, ' order ' and $this->_order            ); foreach ($dataArr as $key = = $value) {$url. = $key. '=' . $value.            "&";            }//Echo $url;            $curl = Curl_init ();            curl_setopt ($curl, Curlopt_url, $url);            curl_setopt ($curl, Curlopt_header, 0);            curl_setopt ($curl, Curlopt_returntransfer, 1);            curl_setopt ($curl, Curlopt_timeout, 10);            $kuaidresult = curl_exec ($curl);            Curl_close ($curl);            if ($this->_show = = 0) {$result = Json_decode ($kuaidresult, true);            }else{$result = $kuaidresult;        } return $result;         }else{throw new Exception ("Please install Curl plugin", 1); }    }}
  • 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.