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; } }
/** * @brief 从华强宝提供的的物流跟踪API,获取物流轨迹 * * @param string $LogisticCode 物流单号 * @param string $ShipperCode 快递公司编号 * * @return array */ public function pullFromHqepay($LogisticCode, $ShipperCode) { //请求类型 1002表示查询订单轨迹 $RequestType = 1002; //华强宝配置数据 $hqepayParams = app::get('syslogistics')->getConf('syslogistics.order.hqepay'); //电商ID $EBusinessID = !empty($hqepayParams['id']) ? $hqepayParams['id'] : '1226825'; //AppKey $appkey = !empty($hqepayParams['appkey']) ? $hqepayParams['appkey'] : '9326bc57-8964-4f59-88fe-b5ced1dfd66a'; //参数内容 $content = "<Content><OrderCode></OrderCode><ShipperCode>{$ShipperCode}</ShipperCode><LogisticCode>{$LogisticCode}</LogisticCode></Content>"; //签名 $DataSign = $this->__hqepayEncrypt($content, $appkey); $post = array('RequestType' => $RequestType, 'EBusinessID' => $EBusinessID, 'RequestData' => urlencode($content), 'DataSign' => urlencode($DataSign)); $httpclient = new base_httpclient(); $response = $httpclient->post($this->hqepayApiUrl, $post); $responseData = kernel::single('site_utility_xml')->xml2arrayValues($response); if ($responseData) { if ($responseData['Response']['Success']['value'] == 'false') { throw new \LogicException($responseData['Response']['Reason']['value']); } if ($responseData['Response']['Success']['value'] == 'true') { $traces = array(); foreach ($responseData['Response']['Traces']['Trace'] as $key => $value) { $traces[$key]['AcceptTime'] = $value['AcceptTime']['value']; $traces[$key]['AcceptStation'] = strip_tags($value['AcceptStation']['value']); } return $traces; } } else { throw new \LogicException(app::get('syslogistics')->_('查询失败,请到快递公司官网查询')); } }
function runtask($task_id) { $http = new base_httpclient(); $_POST['task_id'] = $task_id; $url = kernel::openapi_url('openapi.queue', 'worker', array('task_id' => $task_id)); logger::info('Spawn [Task-' . $task_id . '] ' . $url); //99%概率不会有问题 $http->hostaddr = $_SERVER["SERVER_ADDR"] ? $_SERVER["SERVER_ADDR"] : '127.0.0.1'; $http->hostport = $_SERVER["SERVER_PORT"] ? $_SERVER["SERVER_PORT"] : '80'; $http->set_timeout(2); logger::info($http->post($url, $_POST)); }
private static function pull_from_matrix($logi_no, $dlycorp_code, &$hock) { $logi_no = preg_replace('/\\xEF\\xBB\\xBF/', '', $logi_no); $logi = array('format' => 'json', 'date' => time(), 'method' => 'logistics.trace.search', 'tracking_no' => $logi_no, 'logistics_code' => $dlycorp_code); $logi['certi_id'] = base_certificate::certi_id(); $logi['sign'] = base_certificate::gen_sign($logi); $httpclient = new base_httpclient(); $response = $httpclient->post(MATRIX_RELATION_URL . 'service/', $logi); $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; } }