Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for oauth2-client 2.x support #14

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $provider = new J4k\OAuth2\Client\Provider\Vkontakte([
'clientId' => '1234567',
'clientSecret' => 's0meRe4lLySEcRetC0De',
'redirectUri' => 'https://example.org/oauth-endpoint',
'scopes' => ['email', 'offline', 'friends'],
'scope' => ['email', 'offline', 'friends'],
]);
```

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
}
],
"require": {
"php" : ">=5.5",
"league/oauth2-client": "^1.4"
"php" : ">=5.6",
"league/oauth2-client": "^2.0"
},
"require-dev": {
"phpunit/phpunit" : "~4.6",
Expand Down
12 changes: 6 additions & 6 deletions src/Vkontakte.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Vkontakte extends AbstractProvider
{
protected $baseOAuthUri = 'https://oauth.vk.com';
protected $baseUri = 'https://api.vk.com/method';
protected $version = '5.52';
protected $version = '5.63';
protected $language = null;

/**
Expand Down Expand Up @@ -190,7 +190,7 @@ protected function createResourceOwner(array $response, AccessToken $token)
$response['id'] = $additional['user_id'];
}

return new User($response, $response['id']);
return new VkontakteUser($response, $response['id']);
}

/**
Expand All @@ -200,7 +200,7 @@ protected function createResourceOwner(array $response, AccessToken $token)
* @param AccessToken|null $token Current user if empty
* @param array $params
*
* @return User[]
* @return VkontakteUser[]
*/
public function usersGet(array $ids = [], AccessToken $token = null, array $params = [])
{
Expand All @@ -222,7 +222,7 @@ public function usersGet(array $ids = [], AccessToken $token = null, array $para
$response = $this->getResponse($this->createRequest(static::METHOD_GET, $url, $token, []))['response'];
$users = !empty($response['items']) ? $response['items'] : $response;
$array2user = function ($userData) {
return new User($userData);
return new VkontakteUser($userData);
};

return array_map($array2user, $users);
Expand All @@ -234,7 +234,7 @@ public function usersGet(array $ids = [], AccessToken $token = null, array $para
* @param AccessToken|null $token
* @param array $params
*
* @return User[]
* @return VkontakteUser[]
*/
public function friendsGet($userId, AccessToken $token = null, array $params = [])
{
Expand All @@ -256,7 +256,7 @@ public function friendsGet($userId, AccessToken $token = null, array $params = [
$friendData = ['id' => $friendData];
}

return new User($friendData);
return new VkontakteUser($friendData);
};

return array_map($array2friend, $friends);
Expand Down
2 changes: 1 addition & 1 deletion src/User.php → src/VkontakteUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @package J4k\OAuth2\Client\Provider
*/
class User implements ResourceOwnerInterface
class VkontakteUser implements ResourceOwnerInterface
{
/**
* @type array
Expand Down