diff --git a/src/snapchat.php b/src/snapchat.php index fe64534..2fa4751 100755 --- a/src/snapchat.php +++ b/src/snapchat.php @@ -230,18 +230,18 @@ public function register($username, $password, $email, $birthday) { * The data returned by the service or FALSE on failure. */ public function getUpdates($force = FALSE) { - if (!$force) { + // Make sure we're logged in and have a valid access token. + if (!$this->auth_token || !$this->username) { + return FALSE; + } + + if (!$force && isset($this->cache)) { $result = $this->cache->get('updates'); if ($result) { return $result; } } - // Make sure we're logged in and have a valid access token. - if (!$this->auth_token || !$this->username) { - return FALSE; - } - $timestamp = parent::timestamp(); $result = parent::post( '/all_updates', @@ -257,7 +257,9 @@ public function getUpdates($force = FALSE) { if (!empty($result->updates_response)) { $this->auth_token = $result->updates_response->auth_token; - $this->cache->set('updates', $result->updates_response); + if (isset($this->cache)) { + $this->cache->set('updates', $result->updates_response); + } return $result->updates_response; } @@ -313,18 +315,18 @@ public function getSnaps() { * An array of stories or FALSE on failure. */ function getFriendStories($force = FALSE) { - if (!$force) { + // Make sure we're logged in and have a valid access token. + if (!$this->auth_token || !$this->username) { + return FALSE; + } + + if (!$force && isset($this->cache)) { $result = $this->cache->get('stories'); if ($result) { return $result; } } - // Make sure we're logged in and have a valid access token. - if (!$this->auth_token || !$this->username) { - return FALSE; - } - $timestamp = parent::timestamp(); $result = parent::post( '/all_updates', @@ -338,7 +340,7 @@ function getFriendStories($force = FALSE) { ) ); - if (!empty($result->stories_response)) { + if (isset($this->cache) && !empty($result->stories_response)) { $this->cache->set('stories', $result->stories_response); } else {