Home php教程 PHP源码 PHP express API interface unlimited free

PHP express API interface unlimited free

Nov 08, 2016 am 11:07 AM

Express delivery inquiry interface API and logistics inquiry interface API integrate all logistics inquiries, express delivery order number inquiries, outlet inquiries and complaint phone inquiries such as EMS, YTO, Zhongtong, Debon, etc., free to use

1.KuadidiAPI.php No need to change anything
2.example.php Use according to the instructions
3. If there is anything unclear, please go to the official website of Express.com (http://www.kuaidi.com/), the API interface application address of Express.com (http:/ /www.kuaidi.com/openapi.html)

<?php
/**
 * Created by http://www.kuaidi.com
 * User: kuaidi.com PHP team
 * Date: 2016-03-02
 * 物流信息查询接口SDK
 * QQ: 524654214(群)
 * Version 1.0
 */
 
class KuaidiAPI{
     
    private $_APPKEY = &#39;&#39;; 
     
    private $_APIURL = "http://highapi.kuaidi.com/openapi-querycountordernumber.html?";
     
    private $_show = 0;
 
    private $_muti = 0;
 
    private $_order = &#39;desc&#39;;
     
    /**
     * 您获得的快递网接口查询KEY。
     * @param string $key
     */
    public function KuaidiAPi($key){
        $this->_APPKEY = $key;
    }
 
    /**
     * 设置数据返回类型。0: 返回 json 字符串; 1:返回 xml 对象
     * @param number $show
     */
    public function setShow($show = 0){
        $this->_show = $show;
    }
     
    /**
     * 设置返回物流信息条目数, 0:返回多行完整的信息; 1:只返回一行信息
     * @param number $muti
     */
    public function setMuti($muti = 0){
        $this->_muti = $muti;
    }
     
    /**
     * 设置返回物流信息排序。desc:按时间由新到旧排列; asc:按时间由旧到新排列
     * @param string $order
     */
    public function setOrder($order = &#39;desc&#39;){
        $this->_order = $order;
    }
 
    /**
     * 查询物流信息,传入单号,
     * @param 物流单号 $nu
     * @param 公司简码 $com 要查询的快递公司代码,不支持中文,具体请参考快递公司代码文档。 不填默认根据单号自动匹配公司。注:单号匹配成功率高于 95%。
     * @throws Exception
     * @return array
     */
    public function query($nu, $com=&#39;&#39;){
        if (function_exists(&#39;curl_init&#39;) == 1) {
             
            $url = $this->_APIURL;
 
            $dataArr = array(
                &#39;id&#39; => $this->_APPKEY,
                &#39;com&#39; => $com,
                &#39;nu&#39; => $nu,
                &#39;show&#39; => $this->_show,
                &#39;muti&#39; => $this->_muti,
                &#39;order&#39; => $this->_order
            );
 
            foreach ($dataArr as $key => $value) {
                $url .= $key . &#39;=&#39; . $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); 
        }
    }
 
}
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)