<?php
/** 
 * UQ云商：	www.uqcms.com  
 * 联系QQ：	2200631718 
 * 可免费商用，需要留UQ云商链接作为交换，只首页底部留取即可，不影响使用。
 */
  defined('IN_UQ') or exit('Access Denied'); class express_kdniao { private static $uq0; public static function init(){ if (is_null(self::$uq0)){ self::$uq0 = new self(); } return self::$uq0; } function __construct($uq1) { $this->appid = $uq1['appid']; $this->appkey = $uq1['appkey']; } public function query($uq2, $uq3) { $uq2 = strtoupper($uq2); $uq4 = 'http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx'; $uq1 = [ 'ShipperCode' =>$uq2, 'LogisticCode' =>$uq3 ]; $uq5 = json_encode($uq1); $uq6 = $this->queryOrder($uq4, $uq5); $uq7 = json_decode($uq6); if($uq7->Success == '1'){ if($uq7->Traces != ''){ foreach($uq7->Traces as $uq8){ $uq9[] = [ 'time'=>$uq8->AcceptTime, 'content'=>$uq8->AcceptStation, ]; } $uq10['error'] = '0'; $uq10['list'] = array_reverse($uq9); return $uq10; }else{ $uq10['error'] = '1'; $uq10['msg'] = '暂无物流信息'; return $uq10; } }else{ $uq10['error'] = '1'; $uq10['msg'] = $uq7->Reason; return $uq10; } } function queryOrder($uq11, $uq12) { $uq13 = [ 'RequestData' => urlencode($uq12) , 'EBusinessID' => $this->appid, 'RequestType' => '1002', 'DataType' => '2', ]; $uq13['DataSign'] = $this->encrypt($uq12, $this->appkey); $uq7 = curl::post($uq11, $uq13); return $uq7; } function sendPost($uq4, $uq13) { $uq14 = array(); foreach ($uq13 as $uq15 => $uq16) { $uq14[] = sprintf('%s=%s', $uq15, $uq16); } $uq17 = implode('&', $uq14); $uq18 = parse_url($uq4); if(empty($uq18['port'])){ $uq18['port']=80; } $uq19 = "POST " . $uq18['path'] . " HTTP/1.0\r\n"; $uq19.= "Host:" . $uq18['host'] . "\r\n"; $uq19.= "Content-Type:application/x-www-form-urlencoded\r\n"; $uq19.= "Content-Length:" . strlen($uq17) . "\r\n"; $uq19.= "Connection:close\r\n\r\n"; $uq19.= $uq17; $uq20 = fsockopen($uq18['host'], $uq18['port']); fwrite($uq20, $uq19); $uq21 = ""; $uq22 = true; while(!feof($uq20)){ if(($uq23 = @fgets($uq20)) && ($uq23 == "\r\n" || $uq23 == "\n")){ break; } } while(!feof($uq20)){ $uq21.= fread($uq20, 128); } fclose($uq20); return $uq21; } function json_utf8($uq16) { if (version_compare(PHP_VERSION,'5.4.0','<')){ $uq24 = json_encode($uq16); $uq24 = preg_replace_callback("#\\\u([0-9a-f]{4})#i",function($uq25){ return iconv('UCS-2BE', 'UTF-8', pack('H4', $uq25[1])); },$uq24); return $uq24; }else{ return json_encode($uq16, JSON_UNESCAPED_UNICODE); } } function encrypt($uq10, $uq26) { return urlencode(base64_encode(md5($uq10.$uq26))); } } 