php 免费的快递查询接口快递100

这个快递100的接口是免费的,但是查询过频繁的话可能就没什么效果了。项目比较正规的话还是建议通过申请企业版的物流接口

直接上代码:

public function get_expressOp(){
        $url = 'http://www.kuaidi100.com/query?type='.$_GET['e_code'].'&postid='.$_GET['shipping_code'].'&id=1&valicode=&temp='.random(4).'&sessionid=&tmp='.random(4);
        import('function.ftp');
        $content = dfsockopen($url);
        $content = json_decode($content,true);
        $state=$content['state'];
        if ($content['status'] != 200) exit(json_encode(false));
        $content['data'] = array_reverse($content['data']);//返回来的物流信息,根据需要整理成自己的想要的结构
        $output = '';
        $arr=array();
        if (is_array($content['data'])){
            for($i=count($content['data']);$i>0;$i--){
                $arr[]=$content['data'][$i];

            }
            foreach($arr as $k =>$v){
                if ($v['time'] == '') continue;
                $content=$v['context'];
                $info_time=$v['time'];
                $output.="<li succeed=$state class='typ'>".'<div class="cll-l" ><div class="ball"></div><div class="xian"></div></div>'."<div class='cll-r'><div><i class='iconfont'>&#xe612;</i></div><p>$content</p><samp>$info_time</samp> </div>". "<div class='clear'></div>".'</li>';

            }

        }
        if ($output == '') exit(json_encode(false));
        if (strtoupper(CHARSET) == 'GBK'){
            $output = Language::getUTF8($output);//网站GBK使用编码时,转换为UTF-8,防止json输出汉字问题

        }
        echo json_encode($output);

    }

注释:
$_GET['e_code']  你的快递公司的字母拼音。
$_GET['shipping_code']  查询的单号
 
 

 

转载于:https://www.cnblogs.com/lixiaoquan/p/6928827.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值