function uk86_getremotefile($file) { @set_time_limit(0); $file = $file . '?' . time() . rand(1000, 9999); $str = @implode('', @file($file)); if (!$str) { $str = uk86_dfsockopen($file); } return $str; }
/** * 从第三方取快递信息 */ public function ajax_get_expressOp() { $url = 'http://www.kuaidi100.com/query?type=' . $_GET['e_code'] . '&postid=' . $_GET['shipping_code'] . '&id=1&valicode=&temp=' . uk86_random(4) . '&sessionid=&tmp=' . uk86_random(4); uk86_import('function.ftp'); $content = uk86_dfsockopen($url); $content = json_decode($content, true); if ($content['status'] != 200) { exit(json_encode(false)); } $content['data'] = array_reverse($content['data']); $output = array(); if (is_array($content['data'])) { foreach ($content['data'] as $k => $v) { if ($v['time'] == '') { continue; } $output[] = $v['time'] . ' ' . $v['context']; } } if (empty($output)) { exit(json_encode(false)); } echo json_encode($output); }
/** * 从第三方取快递信息 * */ public function get_expressOp() { $url = 'http://www.kuaidi100.com/query?type=' . $_GET['e_code'] . '&postid=' . $_GET['shipping_code'] . '&id=1&valicode=&temp=' . uk86_random(4) . '&sessionid=&tmp=' . uk86_random(4); uk86_import('function.ftp'); $content = uk86_dfsockopen($url); $content = json_decode($content, true); if ($content['status'] != 200) { exit(json_encode(false)); } $content['data'] = array_reverse($content['data']); $output = ''; if (is_array($content['data'])) { foreach ($content['data'] as $k => $v) { if ($v['time'] == '') { continue; } $output .= '<li>' . $v['time'] . ' ' . $v['context'] . '</li>'; } } if ($output == '') { exit(json_encode(false)); } if (strtoupper(CHARSET) == 'GBK') { $output = Uk86Language::uk86_getUTF8($output); //网站GBK使用编码时,转换为UTF-8,防止json输出汉字问题 } echo json_encode($output); }