private function _verifyOrder($params) { $url = self::VERIFY_URL_ONLINE; unset($params['gateway_flag'], $params['sign'], $params['sign_return']); $params['app_key'] = $this->_appKey; $params['sign'] = Qihoo_Util::getSign($params, $this->_appSecret); $url .= '?' . http_build_query($params); $ret = Qihoo_Util::request($url, Qihoo_Util::METHOD_POST); $json = json_decode($ret, TRUE); return $json['ret']; }
/** * 请求360接口 * @param type $url * @param type $data * @param type $decode * @return type * @throws Qihoo_Exception */ private function _request($url, $data, $decode = true) { $debugUrl = $url . '?' . http_build_query($data); $this->_debug(__METHOD__, "请求 {$debugUrl}"); $jsonStr = Qihoo_Util::request($url, Qihoo_Util::METHOD_GET, $data); $err = Qihoo_Util::getError(); if ($err) { $errMsg = "错误:{$err['error']}({$err['errno']})"; $this->_debug(__METHOD__, $errMsg); throw new Qihoo_Exception(Qihoo_Exception::CODE_NET_ERROR, $errMsg . "\r\n" . $url); } if (empty($jsonStr)) { $this->_debug(__METHOD__, "请求{$debugUrl} 返回了空字符串"); throw new Qihoo_Exception(Qihoo_Exception::CODE_NET_ERROR, $debugUrl); } $this->_debug(__METHOD__, "请求{$debugUrl} 返回了" . $jsonStr); if (!$decode) { return $jsonStr; } $response = json_decode($jsonStr, true); if (empty($response)) { $this->_debug(__METHOD__, "json_decode失败,原串为{$jsonStr}"); throw new Qihoo_Exception(Qihoo_Exception::CODE_JSON_ERROR, $jsonStr); } $this->_debug(__METHOD__, "请求{$debugUrl} json解压后结果为" . var_export($response, 1)); if (!empty($response['error_code'])) { $this->_debug(__METHOD__, "返回结果有错误:" . $response['error'] . "({$response['error_code']})"); throw new Qihoo_Exception($response['error_code'], $response['error']); } return $response; }