├── Express.class.php └── README.md /Express.class.php: -------------------------------------------------------------------------------- 1 | getContent("http://www.kuaidi100.com/autonumber/autoComNum?text=".$order_no); 43 | $data = json_decode($result,true); 44 | 45 | return $data; 46 | 47 | } 48 | 49 | 50 | /** 51 | * @desc http://www.kuaidi100.com/query?type=zhongtong&postid=453371918456&id=1&valicode=&temp=0.40349807080624434 52 | * @desc 返回的数据结果参考官方文档:https://www.kuaidi100.com/openapi/api_post.shtml 53 | * @desc 直接调用该方法,传入物流单号即可查询物流信息 54 | * @param string $order_no 55 | * @return bool|mixed 56 | */ 57 | public function getLogisticsInfo($order_no=''){ 58 | 59 | $result = $this->getOrder($order_no); 60 | $auto_arr = $result['auto']; 61 | 62 | if(count($auto_arr)>0){ 63 | foreach ($auto_arr as $key => $value){ 64 | $temp = $this->randFloat(); 65 | $comCode = $value['comCode']; 66 | $url = "http://www.kuaidi100.com/query?type=$comCode&postid=$order_no&id=1&valicode=&temp=$temp";// $temp 随机数,防止缓存 67 | $json = $this->getContent($url); 68 | $data = json_decode($json,true); 69 | if($data['message']=='ok'){ 70 | return $data; 71 | } 72 | } 73 | } 74 | 75 | return false; 76 | 77 | } 78 | 79 | 80 | /** 81 | * 生成0~1随机小数 82 | * @param Int $min 83 | * @param Int $max 84 | * @return Float 85 | */ 86 | function randFloat($min=0, $max=1){ 87 | 88 | return $min + mt_rand()/mt_getrandmax() * ($max-$min); 89 | 90 | } 91 | 92 | 93 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Express 2 | 快递公司,只要直接输入快递单号就可以自动识别快递单号所在快递公司和物流信息,还是非常方便的,只要几行代码就可以完美的集成到你系统的功能中了! 3 | 4 | 使用示例: 5 | 使用如下,只需要调用类中的getLogisticsInfo()方法,参数传入订单号即可 6 | 7 | ```php 8 | getLogisticsInfo("453371918456"); 12 | 13 | 14 | var_dump($data); 15 | --------------------------------------------------------------------------------