Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/vendor/league/oauth2-client/src/Provider/Vkontakte.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/league/oauth2-client/src/Provider/Vkontakte.php')
-rw-r--r--vendor/league/oauth2-client/src/Provider/Vkontakte.php99
1 files changed, 99 insertions, 0 deletions
diff --git a/vendor/league/oauth2-client/src/Provider/Vkontakte.php b/vendor/league/oauth2-client/src/Provider/Vkontakte.php
new file mode 100644
index 0000000..da44ae2
--- /dev/null
+++ b/vendor/league/oauth2-client/src/Provider/Vkontakte.php
@@ -0,0 +1,99 @@
+<?php
+
+namespace League\OAuth2\Client\Provider;
+
+use League\OAuth2\Client\Entity\User;
+use League\OAuth2\Client\Token\AccessToken;
+
+class Vkontakte extends AbstractProvider
+{
+ public $uidKey = 'user_id';
+
+ public function urlAuthorize()
+ {
+ return 'https://oauth.vk.com/authorize';
+ }
+
+ public function urlAccessToken()
+ {
+ return 'https://oauth.vk.com/access_token';
+ }
+
+ public function urlUserDetails(AccessToken $token)
+ {
+ $fields = ['nickname',
+ 'screen_name',
+ 'sex',
+ 'bdate',
+ 'city',
+ 'country',
+ 'timezone',
+ 'photo_50',
+ 'photo_100',
+ 'photo_200_orig',
+ 'has_mobile',
+ 'contacts',
+ 'education',
+ 'online',
+ 'counters',
+ 'relation',
+ 'last_seen',
+ 'status',
+ 'can_write_private_message',
+ 'can_see_all_posts',
+ 'can_see_audio',
+ 'can_post',
+ 'universities',
+ 'schools',
+ 'verified', ];
+
+ return "https://api.vk.com/method/users.get?user_id={$token->uid}&fields="
+ .implode(",", $fields)."&access_token={$token}";
+ }
+
+ public function userDetails($response, AccessToken $token)
+ {
+ $response = $response->response[0];
+
+ $user = new User();
+
+ $email = (isset($response->email)) ? $response->email : null;
+ $location = (isset($response->country)) ? $response->country : null;
+ $description = (isset($response->status)) ? $response->status : null;
+
+ $user->exchangeArray([
+ 'uid' => $response->uid,
+ 'nickname' => $response->nickname,
+ 'name' => $response->screen_name,
+ 'firstname' => $response->first_name,
+ 'lastname' => $response->last_name,
+ 'email' => $email,
+ 'location' => $location,
+ 'description' => $description,
+ 'imageUrl' => $response->photo_200_orig,
+ ]);
+
+ return $user;
+ }
+
+ public function userUid($response, AccessToken $token)
+ {
+ $response = $response->response[0];
+
+ return $response->uid;
+ }
+
+ public function userEmail($response, AccessToken $token)
+ {
+ $response = $response->response[0];
+
+ return isset($response->email) && $response->email ? $response->email : null;
+ }
+
+ public function userScreenName($response, AccessToken $token)
+ {
+ $response = $response->response[0];
+
+ return [$response->first_name, $response->last_name];
+ }
+}