Skip to content

Commit

Permalink
Use the latest Graph Api (fix #65)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nodge committed Jan 3, 2016
1 parent f38eca2 commit a00e9d5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Yii2 EAuth Change Log

### dev
* Fixed error param names for Facebook (#63)
* Use the latest Graph Api v2.5 for Facebook (#65)

### 2.3.0 (17.10.2015)
* Added InstagramOAuth2Service (#61)
Expand Down
12 changes: 10 additions & 2 deletions src/services/FacebookOAuth2Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,19 @@ class FacebookOAuth2Service extends Service
'authorize' => 'https://www.facebook.com/dialog/oauth',
'access_token' => 'https://graph.facebook.com/oauth/access_token',
];
protected $baseApiUrl = 'https://graph.facebook.com/';
protected $baseApiUrl = 'https://graph.facebook.com/v2.5/';

protected function fetchAttributes()
{
$info = $this->makeSignedRequest('me');
$info = $this->makeSignedRequest('me', [
'query' => [
'fields' => join(',', [
'id',
'name',
'link'
])
]
]);

$this->attributes['id'] = $info['id'];
$this->attributes['name'] = $info['name'];
Expand Down
53 changes: 36 additions & 17 deletions src/services/extended/FacebookOAuth2Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,41 @@
class FacebookOAuth2Service extends \nodge\eauth\services\FacebookOAuth2Service
{

protected $scopes = [
self::SCOPE_EMAIL,
self::SCOPE_USER_BIRTHDAY,
self::SCOPE_USER_HOMETOWN,
self::SCOPE_USER_LOCATION,
self::SCOPE_USER_PHOTOS,
];
protected $scopes = [
self::SCOPE_EMAIL,
self::SCOPE_USER_BIRTHDAY,
self::SCOPE_USER_HOMETOWN,
self::SCOPE_USER_LOCATION,
self::SCOPE_USER_PHOTOS,
];

/**
* http://developers.facebook.com/docs/reference/api/user/
*
* @see FacebookOAuth2Service::fetchAttributes()
*/
protected function fetchAttributes()
{
$this->attributes = $this->makeSignedRequest('me');
return true;
}
/**
* http://developers.facebook.com/docs/reference/api/user/
*
* @see FacebookOAuth2Service::fetchAttributes()
*/
protected function fetchAttributes()
{
$this->attributes = $this->makeSignedRequest('me', [
'query' => [
'fields' => join(',', [
'id',
'name',
'link',
'email',
'verified',
'first_name',
'last_name',
'gender',
'birthday',
'hometown',
'location',
'locale',
'timezone',
'updated_time',
])
]
]);
return true;
}
}

0 comments on commit a00e9d5

Please sign in to comment.