Skip to content

Commit

Permalink
Fix stdClass error on FacebookRedirectLoginHelper because response ha…
Browse files Browse the repository at this point in the history
…ndling is kinda 💩
  • Loading branch information
SammyK committed Apr 3, 2015
1 parent 0017521 commit 46d5de0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Facebook/FacebookRedirectLoginHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,17 @@ public function getSessionFromRedirect()
'/oauth/access_token',
$params
))->execute()->getResponse();
if (isset($response['access_token'])) {
return new FacebookSession($response['access_token']);

// Graph v2.3 and greater return objects on the /oauth/access_token endpoint
$accessToken = null;
if (is_object($response) && isset($response->access_token)) {
$accessToken = $response->access_token;
} elseif (is_array($response) && isset($response['access_token'])) {
$accessToken = $response['access_token'];
}

if (isset($accessToken)) {
return new FacebookSession($accessToken);
}
}
return null;
Expand Down

0 comments on commit 46d5de0

Please sign in to comment.