Express API interface docking analysis

1. Express query API interface

       For the current online shopping, "Where did I send the things I bought?" This is a question that every buyer is more and more concerned about, "Is the customer's experience effect of the logistics information tracking service in my mall still satisfactory?" This is every This is a problem that sellers are more and more worried about, because in modern society, people not only care about the value of the product itself, but also care about the value of the service!

At present, there are two modes of express query API, one is instant query, that is to say, the data will be returned when a request is made; the other is subscription query, when the subscribed express order number has updated logistics information, it will be returned. data, no request is required. At present, the domestic express query API interface is well done, such as express network and express 100.

The interface of the express network has two access modes, one is the free version (you need to add a friend chain), which supports all express inquiries without limitation, 500 times per day for free; the other is the enterprise version, which supports more than 300 without any restrictions. Inquiries from express and logistics companies. Features: fast response! Strong stability! Cheap price (0.03-0.05 yuan per order)!

       The interface of Express 100 is also divided into two access modes, one is the free version (you need to add a friend chain), there are several commonly used express companies such as Sitong Yida do not support query, free 2000 times a day; the other It is a paid version, which supports unlimited inquiries from more than 300 express delivery companies. Features: Fast response! Strong stability! The price is more expensive (0.08-0.1 yuan per order)!

2. Docking example

      The following is an example of the instant query access of the free trial version API interface of the express network. The difference is that there is no need to apply for a KEY. There are KEY and ID available in the document. After the user integrates, enter the express tracking number and express company code. The query function can be realized. The receiving method of the interface is get, and the format of the data returned is JSON and XML.

 

3. Definition of interface parameters:

 


 

 

4. Return result definition:

5. Example of docking access:

First integrate KuaidiAPI.php and example.php source code. The query can be realized according to the instructions for use.

Documentation:

1. KuadidiAPI.php does not need to be modified or changed.
2. Example.php is used according to the instructions.
3. For the code of the express company, see the technical document of the code of the express company
. //www.kuaidi.com/), or call the express network for consultation: 18205167920 or add qq: 2885643506 and send an email to [email protected]

1. KuaidiAPI.php

 

<?php
/**
 * Created by http://www.kuaidi.com
 * User: kuaidi.com PHP team
 * Date: 2016-03-02
 * Logistics information query interface SDK
 * QQ: 2885643506
 * Version 1.0
 */

class KuaidiAPI{
    
    private $_APPKEY = '';
    
    private $_APIURL = "http://highapi.kuaidi.com/openapi-querycountordernumber.html?";
    
    private $_show = 0;

    private $_muti = 0;

    private $_order = 'desc';
    
    /**
     * You obtained the express network interface query KEY.
     * @param string $key
     */
    public function KuaidiAPi($key){
        $this->_APPKEY = $key;
    }

    /**
     * Set the data return type. 0: return json string; 1: return xml object
     * @param number $show
     */
    public function setShow($show = 0){
        $this->_show = $show;
    }
    
    /**
     * Set the number of returned logistics information items, 0: return multiple lines of complete information; 1: return only one line of information
     * @param number $ muti
     */
    public function setMuti($muti = 0){
        $ this -> _ muti = $ muti;
    }
    
    /**
     * Set return logistics information sorting. desc: sort by time from new to old; asc: sort by time from old to new
     * @param string $order
     */
    public function setOrder($order = 'desc'){
        $this->_order = $order;
    }

    /**
     * Query logistics information, pass in the order number,
     * @param logistics order number $nu
     * @param company short code $com The courier company code to be queried, does not support Chinese, please refer to the courier company code document for details.
     * @throws Exception
     * @return array
     */
    public function query($nu, $com=''){
        if (function_exists('curl_init') == 1) {
            
            $url = $this->_APIURL;

            $dataArr = array(
                'id' => $this->_APPKEY,
                'com' => $com,
                'now' => $now,
                'show' => $this->_show,
                'muti' => $this->_muti,
                'order' => $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);
        }
    }

}


2.example.php

 

<?php

include 'KuaidiAPI.php';

//Modify to your own KEY
$key = 'c684ab43a28bc3caea53570666ce9762';

$kuaidichaxun = new KuaidiAPi($key);

//Set the return format. 0: return json string; 1: return xml object
//$kuaidichaxun->setShow(1); //Optional, the default is 0 Return to json format

//Return the number of logistics information items. 0: Return multiple lines of complete information; 1: Return only one line of information
//$kuaidichaxun->setMuti(1); //Optional, default is 0

//Set the return logistics information sorting. desc: sort by time from new to old; asc: sort by time from old to new
//$kuaidichaxun->setOrder('asc');

//Inquire
$result = $kuaidichaxun->query('111111', 'quanfengkuaidi');

//Query with company short code, see document for short code list
//$result = $kuaidichaxun->query('111111', 'quanfengkuaidi');

//111111 Express tracking number
//quanfengkuaidi express company name


var_dump($result);


Courier company code technical document download address: https://pan.baidu.com/s/1miGqMFY

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326493596&siteId=291194637