private static function pull_from_matrix($logi_no, $dlycorp_code, &$hock) { $url = 'http://api.kuaidi100.com/api?'; $logi_no = preg_replace('/\\xEF\\xBB\\xBF/', '', $logi_no); $params = array('id' => app::get('logisticstrack')->getConf('kuaidi100Key'), 'nu' => $logi_no, 'com' => $dlycorp_code); $url .= http_build_query($params); $httpclient = new base_httpclient(); $response = $httpclient->get($url); $hock = json_decode($response, 1); if ($hock['status'] == 2) { $url = 'http://www.kuaidi100.com/query?'; $params = array('id' => app::get('logisticstrack')->getConf('kuaidi100Key'), 'postid' => $logi_no, 'type' => $dlycorp_code); $url .= http_build_query($params); $response = $httpclient->get($url); $hock = json_decode($response, 1); } $hock['logi_no'] = $logi_no; $hock['dlycorp_code'] = $dlycorp_code; $hock['msg'] = $hock['message'] ? $hock['message'] : app::get('logisticstrack')->_('系统错误,请联系客服'); if ($hock['status'] == 1 || $hock['message'] == 'ok') { return true; } else { return false; } }
public function pull_from_remote($logi_no, $dlycorp_code, &$msg) { $url = 'http://api.kuaidi100.com/api?'; $logi_no = preg_replace('/\\xEF\\xBB\\xBF/', '', $logi_no); $params = array('id' => app::get('logisticstrack')->getConf('kuaidi100Key'), 'nu' => $logi_no, 'com' => $dlycorp_code); $url .= http_build_query($params); $httpclient = new base_httpclient(); $response = $httpclient->get($url); $response = json_decode($response, 1); $status = intval($response['status']); switch ($status) { case 0: $msg = '无结果'; return false; case 1: //$msg = '跟踪成功'; return $response['data']; default: $msg = 'API接口异常[' . $response['message'] . ']'; return false; } }