index : flyspray | |
Archlinux32 customized Flyspray installation | gitolite user |
summaryrefslogtreecommitdiff |
author | Andreas Baumann <mail@andreasbaumann.cc> | 2020-02-01 09:05:48 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2020-02-01 09:05:48 +0100 |
commit | 6854cb3f4d8219cf1829e32122eb2502a916eae9 (patch) | |
tree | 350feb504587d932e02837a1442b059759927646 /vendor/league/oauth2-client/src/Provider/Vkontakte.php |
-rw-r--r-- | vendor/league/oauth2-client/src/Provider/Vkontakte.php | 99 |
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]; + } +} |