public static function queryGeoCoder($address) { $contents = ''; // query use fsockopen $http = new HttpHelper(); $response = $http->get(sprintf('http://maps.google.com/maps/api/geocode/json?address=%s&sensor=false', urlencode($address))); if (isset($response['body'])) { return json_decode($response['body']); } return null; }
/** * 查询订单接口 * @param type $userId * @param type $cpOrderId */ function queryOrder($userId, $cpOrderId) { $params = array('appId' => Configuration::APP_ID, 'uid' => $userId, 'cpOrderId' => $cpOrderId); $signObj = new SignatureHelper(); $signature = $signObj->sign($params, Configuration::SECRET_KEY); $params['signature'] = $signature; $request = new HttpHelper(); $response = $request->get(Configuration::QUERY_ORDER_URL, $params); //TODO: 后续业务逻辑处理 echo $response; }
public function getProfile($fb_uid) { if (empty($fb_uid)) { throw new FacebookException('Facebook unique id missing.'); } $url = $this->graphURL() . '/' . $fb_uid . '?fields=picture'; try { $http = new HttpHelper(); $result = $http->get($url, array('ssl_verifypeer' => false)); } catch (YException $e) { return; } $result = json_decode($result['body']); return $result; }
public function facebookAuthenticate() { // init vars $item_id = YRequest::getInt('item_id', 0); $item = YTable::getInstance('item')->get($item_id); // get facebook client $connection = CommentHelper::getFacebookClient(); if ($connection) { $code = YRequest::getString('code', ''); $uri = new JURI(); $redirect = $uri->root() . $this->link_base . '&controller=comment&task=facebookauthenticate&item_id=' . $item_id; $url = $connection->getAccessTokenURL($code, $redirect); $http = new HttpHelper(); $result = $http->get($url, array('ssl_verifypeer' => false)); $token = str_replace('access_token=', '', $result['body']); $_SESSION['facebook_access_token'] = $token; } $redirect = JRoute::_(RouteHelper::getItemRoute($item)); $this->setRedirect($redirect); }