ip()]; $header = ['Host' => 'www.kuaidi100.com', 'CLIENT-IP' => $client_ip, 'X-FORWARDED-FOR' => $client_ip]; $autoResult = Http::get("http://www.kuaidi100.com/autonumber/autoComNum?text={$code}", [], ['header' => $header, 'timeout' => 30]); foreach (json_decode($autoResult)->auto as $vo) { $item = self::query($vo->comCode, $code); if (!empty($item) && $item['message'] === 'ok') $result[$vo->comCode] = $item; } return $result; } /** * 查询物流信息 * @param string $expressCode 快递公司编辑 * @param string $expressNo 快递物流编号 * @return array */ public static function query($expressCode, $expressNo) { list($microtime, $clientIp) = [microtime(true), request()->ip()]; $header = ['Host' => 'www.kuaidi100.com', 'CLIENT-IP' => $clientIp, 'X-FORWARDED-FOR' => $clientIp]; $location = "http://www.kuaidi100.com/query?type={$expressCode}&postid={$expressNo}&phone=&temp={$microtime}"; return json_decode(Http::get($location, [], ['header' => $header, 'timeout' => 30]), true); } }