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']  查询的单号
 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM