From 4be73acc8e1e0a2ae5d46a1c4e4c5734a717548c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Maruszczyk?= Date: Tue, 18 Sep 2012 15:15:09 +0200 Subject: [PATCH] Flaga blokujaca wysylanie requestow przy braku code i sesji --- php/GGAPI.php | 11 +++++++++++ 1 file changed, 11 insertions(+) mode change 100644 => 100755 php/GGAPI.php diff --git a/php/GGAPI.php b/php/GGAPI.php old mode 100644 new mode 100755 index dd6851e..e1bc828 --- a/php/GGAPI.php +++ b/php/GGAPI.php @@ -88,6 +88,10 @@ class GGAPI * @desc Dane do odnowienia tokenu użytkownika */ private $refresh_token = null; + /** + * @desc Flaga blokujaca wysylanie requestow przy braku code i sesji + */ + private $do_requests = true; /** * @desc Inicjalizacja * @@ -117,6 +121,8 @@ public function initSession($sessionId = null) { $_SESSION['code'] = $_GET['code']; } + $this->do_requests = false; + if(isset($_SESSION['token_data'])){ $this->setToken($_SESSION['token_data']['access_token'], $_SESSION['token_data']['refresh_token']); } @@ -281,6 +287,7 @@ public function setToken($access_token, $refresh_token){ $this->access_token = $access_token; $this->refresh_token = $refresh_token; + $this->do_requests = true; return $this; } @@ -422,6 +429,10 @@ protected function doRequest($method, $uri, $params = null, $headers = null, $ss */ private function ggApiRequest($method, $uri, $params = null, $headers = null, $ssl = false, $responseType = 'json'){ + if (!$this->do_requests) { + return; + } + $responseType = $responseType === null ? $this->responseType : $responseType; $add_headers = array(); $add_headers[] = 'Expect: ';