PHP—— 商品物流实时查询接口 (快递100API对接)

PHP后台  与前端   对接商品物流信息的接口

运用的 快递100的API接口

public function getExpress() { 
        $user_id = input(post.user_id);
        if(null===$user_id){
            $this->json_error(请传过来用户编号);
        }

        $com = input(post.expresscom);
        $num = input(post.expresssn);
        // $com = ‘zhongtong‘;
        // $num = ‘73124309026125‘;
        $key = Config::get(kuaidi)[key];                      //客户授权key
        $customer = Config::get(kuaidi)[cus];                 //查询公司编号
        $param = array (
            com => $com,           //快递公司编码
            num => $num,   //快递单号
            phone => ‘‘,              //手机号
            from => ‘‘,               //出发地城市
            to => ‘‘,                 //目的地城市
            resultv2 => 1           //开启行政区域解析
        );
    
        //请求参数
        $post_data = array();
        $post_data["customer"] = $customer;
        $post_data["param"] = json_encode($param);
        $sign = md5($post_data["param"].$key.$post_data["customer"]);
        $post_data["sign"] = strtoupper($sign);
        
        $url = http://poll.kuaidi100.com/poll/query.do;   //实时查询请求地址
        
        $params = "";
        foreach ($post_data as $k=>$v) {
            $params .= "$k=".urlencode($v)."&";     //默认UTF-8编码格式
        }
        $post_data = substr($params, 0, -1);
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($ch);
        $data = str_replace("\"", ", $result );
       
        // $data[‘name‘] = config(‘system.express_company‘)[$com][‘statusname‘];
        $data = json_decode($data,true);
        $data[name] = config(system.express_company)[$com][statusname];
        
        $data = json_encode($data);
        $data = json_decode($data);
          $this->json_success($data);
    }

如下图所示

PHP——  商品物流实时查询接口 (快递100API对接)

PHP—— 商品物流实时查询接口 (快递100API对接)

上一篇:跨代的对决 英特尔i7-6700HQ对比i7-4720HQ性能测试


下一篇:IOS TextField属性