本篇将会介绍php快递查询类的相关方法。
快递公司,只要直接输入快递单号就可以自动识别快递单号所在快递公司和物流信息,还是非常方便的,只要几行代码就可以完美的集成到你系统的功能中了!
使用示例: 使用如下,只需要调用类中的getLogisticsInfo()方法,参数传入订单号即可 $e = new Express();
$data = $e->getLogisticsInfo("453371918456");
echo '';var_dump($data);
public function getOrder($order_no=''){
$result = $this->getContent("http://www.kuaidi100.com/autonumber/autoComNum?text=".$order_no);
$data = json_decode($result,true); return $data;
} /**
* @desc http://www.kuaidi100.com/query?type=zhongtong&postid=453371918456&id=1&valicode=&temp=0.40349807080624434
* @desc 返回的数据结果参考官方文档:https://www.kuaidi100.com/openapi/api_post.shtml
* @desc 直接调用该方法,传入物流单号即可查询物流信息
* @param string $order_no
* @return bool|mixed
*/
public function getLogisticsInfo($order_no=''){
$result = $this->getOrder($order_no);
$auto_arr = $result['auto']; if(count($auto_arr)>0){ foreach ($auto_arr as $key => $value){
$temp = $this->randFloat();
$comCode = $value['comCode'];
$url = "http://www.kuaidi100.com/query?type=$comCode&postid=$order_no&id=1&valicode=&temp=$temp";// $temp 随机数,防止缓存
$json = $this->getContent($url);
$data = json_decode($json,true); if($data['message']=='ok'){ return $data;
}
}
} return false;
} /**
* 生成0~1随机小数
* @param Int $min
* @param Int $max
* @return Float
*/
function randFloat($min=0, $max=1){ return $min + mt_rand()/mt_getrandmax() * ($max-$min);
}
}本篇介绍了php快递查询类的方法,更多相关知识请关注php中文网。
相关推荐:
立即学习“PHP免费学习笔记(深入)”;
magento(麦进斗)
Magento是一套专业开源的PHP电子商务系统。Magento设计得非常灵活,具有模块化架构体系和丰富的功能。易于与第三方应用系统无缝集成。Magento开源网店系统的特点主要分以下几大类,网站管理促销和工具国际化支持SEO搜索引擎优化结账方式运输快递支付方式客户服务用户帐户目录管理目录浏览产品展示分析和报表Magento 1.6 主要包含以下新特性:•持久性购物 - 为不同的
下载










