Skip to content

Commit

Permalink
Switch to Graph API 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Apr 1, 2015
1 parent b39d990 commit 6e7e33b
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/FacebookProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
class FacebookProvider extends OAuth2Provider
{
protected $authorizeUrl = "https://www.facebook.com/dialog/oauth";
protected $accessTokenUrl = "https://graph.facebook.com/oauth/access_token";
protected $userDataUrl = "https://graph.facebook.com/me";
protected $accessTokenUrl = "https://graph.facebook.com/v2.3/oauth/access_token";
protected $userDataUrl = "https://graph.facebook.com/v2.3/me";
protected $scope = [
'email',
];
Expand All @@ -27,13 +27,27 @@ protected function getUserDataUrl()
return $this->userDataUrl;
}

protected function parseTokenResponse($response)
protected function requestAccessToken()
{
parse_str($response);
if (! isset($access_token)) {
throw new InvalidAuthorizationCodeException;
$url = $this->getAccessTokenBaseUrl();
try {
$response = $this->httpClient->get($url, [
'query' => [
'client_id' => $this->clientId,
'client_secret' => $this->clientSecret,
'redirect_uri' => $this->redirectUri(),
'code' => $this->request->authorizationCode(),
],
]);
} catch (BadResponseException $e) {
throw new InvalidAuthorizationCodeException((string) $e->getResponse());
}
return $access_token;
return $this->parseTokenResponse((string) $response->getBody());
}

protected function parseTokenResponse($response)
{
return $this->parseJsonTokenResponse($response);
}

protected function parseUserDataResponse($response)
Expand Down

0 comments on commit 6e7e33b

Please sign in to comment.