>  기사  >  php教程  >  PHP 익스프레스 API 인터페이스 무제한 무료

PHP 익스프레스 API 인터페이스 무제한 무료

大家讲道理
大家讲道理원래의
2016-11-08 11:07:341714검색

특급배송 조회 인터페이스 API 및 물류 조회 인터페이스 API는 EMS, YTO, Zhongtong, Debon 등 모든 물류 문의, 특급 주문 번호 조회, 매장 조회 및 불만 전화 문의를 통합하여 무료로 사용 가능

1.KuadidiAPI .php 아무것도 변경할 필요가 없습니다
2.example.php 지침을 따르세요
3. 불분명한 점이 있으면 Express Network 공식 웹사이트(http://www.kuaidi. com/).Express.com API 인터페이스 응용 프로그램 주소(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); 
        }
    }
 
}
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.