php 免费的快递查询接口快递100
16lz
2021-01-22
这个快递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'></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'] 查询的单号
更多相关文章
- ThinkPHP5开发Api接口简单实例
- PHP开发API接口注意事项
- PHP调用内容DES加密的SOAP接口
- php网站 手机归属地查询接口
- 一套PHP做app接口的解决方案
- php写app接口并返回json数据
- PHP环境搭建和编写API接口
- PHP 天巡机票接口
- PHP实现接口方法时出现致命错误