@@ -17,54 +17,54 @@ |
||
17 | 17 | */ |
18 | 18 | class SteemConnect extends OAuth2 |
19 | 19 | { |
20 | - /** |
|
21 | - * {@inheritdoc} |
|
22 | - */ |
|
23 | - protected $scope = 'login,vote'; |
|
20 | + /** |
|
21 | + * {@inheritdoc} |
|
22 | + */ |
|
23 | + protected $scope = 'login,vote'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * {@inheritdoc} |
|
27 | - */ |
|
28 | - protected $apiBaseUrl = 'https://v2.steemconnect.com/'; |
|
25 | + /** |
|
26 | + * {@inheritdoc} |
|
27 | + */ |
|
28 | + protected $apiBaseUrl = 'https://v2.steemconnect.com/'; |
|
29 | 29 | |
30 | - /** |
|
31 | - * {@inheritdoc} |
|
32 | - */ |
|
33 | - protected $authorizeUrl = 'https://v2.steemconnect.com/oauth2/authorize'; |
|
30 | + /** |
|
31 | + * {@inheritdoc} |
|
32 | + */ |
|
33 | + protected $authorizeUrl = 'https://v2.steemconnect.com/oauth2/authorize'; |
|
34 | 34 | |
35 | - /** |
|
36 | - * {@inheritdoc} |
|
37 | - */ |
|
38 | - protected $accessTokenUrl = 'https://v2.steemconnect.com/api/oauth2/token'; |
|
35 | + /** |
|
36 | + * {@inheritdoc} |
|
37 | + */ |
|
38 | + protected $accessTokenUrl = 'https://v2.steemconnect.com/api/oauth2/token'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * {@inheritdoc} |
|
42 | - */ |
|
43 | - protected $apiDocumentation = 'https://steemconnect.com/'; |
|
40 | + /** |
|
41 | + * {@inheritdoc} |
|
42 | + */ |
|
43 | + protected $apiDocumentation = 'https://steemconnect.com/'; |
|
44 | 44 | |
45 | - /** |
|
46 | - * {@inheritdoc} |
|
47 | - */ |
|
48 | - public function getUserProfile() |
|
49 | - { |
|
50 | - $response = $this->apiRequest('api/me'); |
|
45 | + /** |
|
46 | + * {@inheritdoc} |
|
47 | + */ |
|
48 | + public function getUserProfile() |
|
49 | + { |
|
50 | + $response = $this->apiRequest('api/me'); |
|
51 | 51 | |
52 | - $data = new Data\Collection($response); |
|
52 | + $data = new Data\Collection($response); |
|
53 | 53 | |
54 | - if (!$data->exists('result')) { |
|
55 | - throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
56 | - } |
|
54 | + if (!$data->exists('result')) { |
|
55 | + throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
56 | + } |
|
57 | 57 | |
58 | - $userProfile = new User\Profile(); |
|
58 | + $userProfile = new User\Profile(); |
|
59 | 59 | |
60 | - $data = $data->filter('result'); |
|
60 | + $data = $data->filter('result'); |
|
61 | 61 | |
62 | - $userProfile->identifier = $data->get('id'); |
|
63 | - $userProfile->description = $data->get('about'); |
|
64 | - $userProfile->photoURL = $data->get('profile_image'); |
|
65 | - $userProfile->webSiteURL = $data->get('website'); |
|
66 | - $userProfile->displayName = $data->get('name'); |
|
62 | + $userProfile->identifier = $data->get('id'); |
|
63 | + $userProfile->description = $data->get('about'); |
|
64 | + $userProfile->photoURL = $data->get('profile_image'); |
|
65 | + $userProfile->webSiteURL = $data->get('website'); |
|
66 | + $userProfile->displayName = $data->get('name'); |
|
67 | 67 | |
68 | - return $userProfile; |
|
69 | - } |
|
68 | + return $userProfile; |
|
69 | + } |
|
70 | 70 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | |
52 | 52 | $data = new Data\Collection($response); |
53 | 53 | |
54 | - if (!$data->exists('result')) { |
|
54 | + if ( ! $data->exists('result')) { |
|
55 | 55 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
56 | 56 | } |
57 | 57 |
@@ -17,56 +17,56 @@ |
||
17 | 17 | */ |
18 | 18 | class Strava extends OAuth2 |
19 | 19 | { |
20 | - /** |
|
21 | - * {@inheritdoc} |
|
22 | - */ |
|
23 | - protected $scope = 'profile:read_all'; |
|
20 | + /** |
|
21 | + * {@inheritdoc} |
|
22 | + */ |
|
23 | + protected $scope = 'profile:read_all'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * {@inheritdoc} |
|
27 | - */ |
|
28 | - protected $apiBaseUrl = 'https://www.strava.com/api/v3/'; |
|
25 | + /** |
|
26 | + * {@inheritdoc} |
|
27 | + */ |
|
28 | + protected $apiBaseUrl = 'https://www.strava.com/api/v3/'; |
|
29 | 29 | |
30 | - /** |
|
31 | - * {@inheritdoc} |
|
32 | - */ |
|
33 | - protected $authorizeUrl = 'https://www.strava.com/oauth/authorize'; |
|
30 | + /** |
|
31 | + * {@inheritdoc} |
|
32 | + */ |
|
33 | + protected $authorizeUrl = 'https://www.strava.com/oauth/authorize'; |
|
34 | 34 | |
35 | - /** |
|
36 | - * {@inheritdoc} |
|
37 | - */ |
|
38 | - protected $accessTokenUrl = 'https://www.strava.com/oauth/token'; |
|
35 | + /** |
|
36 | + * {@inheritdoc} |
|
37 | + */ |
|
38 | + protected $accessTokenUrl = 'https://www.strava.com/oauth/token'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * {@inheritdoc} |
|
42 | - */ |
|
43 | - protected $apiDocumentation = 'https://developers.strava.com/docs/reference/'; |
|
40 | + /** |
|
41 | + * {@inheritdoc} |
|
42 | + */ |
|
43 | + protected $apiDocumentation = 'https://developers.strava.com/docs/reference/'; |
|
44 | 44 | |
45 | - /** |
|
46 | - * {@inheritdoc} |
|
47 | - */ |
|
48 | - public function getUserProfile() |
|
49 | - { |
|
50 | - $response = $this->apiRequest('athlete'); |
|
45 | + /** |
|
46 | + * {@inheritdoc} |
|
47 | + */ |
|
48 | + public function getUserProfile() |
|
49 | + { |
|
50 | + $response = $this->apiRequest('athlete'); |
|
51 | 51 | |
52 | - $data = new Data\Collection($response); |
|
52 | + $data = new Data\Collection($response); |
|
53 | 53 | |
54 | - if (!$data->exists('id')) { |
|
55 | - throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
56 | - } |
|
54 | + if (!$data->exists('id')) { |
|
55 | + throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
56 | + } |
|
57 | 57 | |
58 | - $userProfile = new User\Profile(); |
|
58 | + $userProfile = new User\Profile(); |
|
59 | 59 | |
60 | - $userProfile->identifier = $data->get('id'); |
|
61 | - $userProfile->firstName = $data->get('firstname'); |
|
62 | - $userProfile->lastName = $data->get('lastname'); |
|
63 | - $userProfile->gender = $data->get('sex'); |
|
64 | - $userProfile->country = $data->get('country'); |
|
65 | - $userProfile->city = $data->get('city'); |
|
66 | - $userProfile->email = $data->get('email'); |
|
60 | + $userProfile->identifier = $data->get('id'); |
|
61 | + $userProfile->firstName = $data->get('firstname'); |
|
62 | + $userProfile->lastName = $data->get('lastname'); |
|
63 | + $userProfile->gender = $data->get('sex'); |
|
64 | + $userProfile->country = $data->get('country'); |
|
65 | + $userProfile->city = $data->get('city'); |
|
66 | + $userProfile->email = $data->get('email'); |
|
67 | 67 | |
68 | - $userProfile->displayName = $userProfile->displayName ?: $data->get('username'); |
|
68 | + $userProfile->displayName = $userProfile->displayName ?: $data->get('username'); |
|
69 | 69 | |
70 | - return $userProfile; |
|
71 | - } |
|
70 | + return $userProfile; |
|
71 | + } |
|
72 | 72 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | |
52 | 52 | $data = new Data\Collection($response); |
53 | 53 | |
54 | - if (!$data->exists('id')) { |
|
54 | + if ( ! $data->exists('id')) { |
|
55 | 55 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
56 | 56 | } |
57 | 57 |
@@ -22,83 +22,83 @@ |
||
22 | 22 | */ |
23 | 23 | class Yahoo extends OAuth2 |
24 | 24 | { |
25 | - /** |
|
26 | - * {@inheritdoc} |
|
27 | - */ |
|
28 | - protected $scope = 'profile'; |
|
29 | - |
|
30 | - /** |
|
31 | - * {@inheritdoc} |
|
32 | - */ |
|
33 | - protected $apiBaseUrl = 'https://api.login.yahoo.com/openid/v1/'; |
|
34 | - |
|
35 | - /** |
|
36 | - * {@inheritdoc} |
|
37 | - */ |
|
38 | - protected $authorizeUrl = 'https://api.login.yahoo.com/oauth2/request_auth'; |
|
39 | - |
|
40 | - /** |
|
41 | - * {@inheritdoc} |
|
42 | - */ |
|
43 | - protected $accessTokenUrl = 'https://api.login.yahoo.com/oauth2/get_token'; |
|
44 | - |
|
45 | - /** |
|
46 | - * {@inheritdoc} |
|
47 | - */ |
|
48 | - protected $apiDocumentation = 'https://developer.yahoo.com/oauth2/guide/'; |
|
49 | - |
|
50 | - /** |
|
51 | - * Currently authenticated user |
|
52 | - */ |
|
53 | - protected $userId = null; |
|
54 | - |
|
55 | - /** |
|
56 | - * {@inheritdoc} |
|
57 | - */ |
|
58 | - protected function initialize() |
|
59 | - { |
|
60 | - parent::initialize(); |
|
61 | - |
|
62 | - $this->tokenExchangeHeaders = [ |
|
63 | - 'Authorization' => 'Basic ' . base64_encode($this->clientId . ':' . $this->clientSecret) |
|
64 | - ]; |
|
65 | - |
|
66 | - $this->tokenRefreshHeaders = $this->tokenExchangeHeaders; |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * {@inheritdoc} |
|
71 | - */ |
|
72 | - public function getUserProfile() |
|
73 | - { |
|
74 | - $response = $this->apiRequest('userinfo'); |
|
75 | - |
|
76 | - $data = new Data\Collection($response); |
|
77 | - |
|
78 | - if (!$data->exists('sub')) { |
|
79 | - throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
80 | - } |
|
81 | - |
|
82 | - $userProfile = new User\Profile(); |
|
83 | - |
|
84 | - $userProfile->identifier = $data->get('sub'); |
|
85 | - $userProfile->firstName = $data->get('given_name'); |
|
86 | - $userProfile->lastName = $data->get('family_name'); |
|
87 | - $userProfile->displayName = $data->get('name'); |
|
88 | - $userProfile->gender = $data->get('gender'); |
|
89 | - $userProfile->language = $data->get('locale'); |
|
90 | - $userProfile->email = $data->get('email'); |
|
91 | - |
|
92 | - $userProfile->emailVerified = $data->get('email_verified') ? $userProfile->email : ''; |
|
93 | - |
|
94 | - $profileImages = $data->get('profile_images'); |
|
95 | - if ($this->config->get('photo_size')) { |
|
96 | - $prop = 'image' . $this->config->get('photo_size'); |
|
97 | - } else { |
|
98 | - $prop = 'image192'; |
|
99 | - } |
|
100 | - $userProfile->photoURL = $profileImages->$prop; |
|
101 | - |
|
102 | - return $userProfile; |
|
103 | - } |
|
25 | + /** |
|
26 | + * {@inheritdoc} |
|
27 | + */ |
|
28 | + protected $scope = 'profile'; |
|
29 | + |
|
30 | + /** |
|
31 | + * {@inheritdoc} |
|
32 | + */ |
|
33 | + protected $apiBaseUrl = 'https://api.login.yahoo.com/openid/v1/'; |
|
34 | + |
|
35 | + /** |
|
36 | + * {@inheritdoc} |
|
37 | + */ |
|
38 | + protected $authorizeUrl = 'https://api.login.yahoo.com/oauth2/request_auth'; |
|
39 | + |
|
40 | + /** |
|
41 | + * {@inheritdoc} |
|
42 | + */ |
|
43 | + protected $accessTokenUrl = 'https://api.login.yahoo.com/oauth2/get_token'; |
|
44 | + |
|
45 | + /** |
|
46 | + * {@inheritdoc} |
|
47 | + */ |
|
48 | + protected $apiDocumentation = 'https://developer.yahoo.com/oauth2/guide/'; |
|
49 | + |
|
50 | + /** |
|
51 | + * Currently authenticated user |
|
52 | + */ |
|
53 | + protected $userId = null; |
|
54 | + |
|
55 | + /** |
|
56 | + * {@inheritdoc} |
|
57 | + */ |
|
58 | + protected function initialize() |
|
59 | + { |
|
60 | + parent::initialize(); |
|
61 | + |
|
62 | + $this->tokenExchangeHeaders = [ |
|
63 | + 'Authorization' => 'Basic ' . base64_encode($this->clientId . ':' . $this->clientSecret) |
|
64 | + ]; |
|
65 | + |
|
66 | + $this->tokenRefreshHeaders = $this->tokenExchangeHeaders; |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * {@inheritdoc} |
|
71 | + */ |
|
72 | + public function getUserProfile() |
|
73 | + { |
|
74 | + $response = $this->apiRequest('userinfo'); |
|
75 | + |
|
76 | + $data = new Data\Collection($response); |
|
77 | + |
|
78 | + if (!$data->exists('sub')) { |
|
79 | + throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
80 | + } |
|
81 | + |
|
82 | + $userProfile = new User\Profile(); |
|
83 | + |
|
84 | + $userProfile->identifier = $data->get('sub'); |
|
85 | + $userProfile->firstName = $data->get('given_name'); |
|
86 | + $userProfile->lastName = $data->get('family_name'); |
|
87 | + $userProfile->displayName = $data->get('name'); |
|
88 | + $userProfile->gender = $data->get('gender'); |
|
89 | + $userProfile->language = $data->get('locale'); |
|
90 | + $userProfile->email = $data->get('email'); |
|
91 | + |
|
92 | + $userProfile->emailVerified = $data->get('email_verified') ? $userProfile->email : ''; |
|
93 | + |
|
94 | + $profileImages = $data->get('profile_images'); |
|
95 | + if ($this->config->get('photo_size')) { |
|
96 | + $prop = 'image' . $this->config->get('photo_size'); |
|
97 | + } else { |
|
98 | + $prop = 'image192'; |
|
99 | + } |
|
100 | + $userProfile->photoURL = $profileImages->$prop; |
|
101 | + |
|
102 | + return $userProfile; |
|
103 | + } |
|
104 | 104 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | parent::initialize(); |
61 | 61 | |
62 | 62 | $this->tokenExchangeHeaders = [ |
63 | - 'Authorization' => 'Basic ' . base64_encode($this->clientId . ':' . $this->clientSecret) |
|
63 | + 'Authorization' => 'Basic '.base64_encode($this->clientId.':'.$this->clientSecret) |
|
64 | 64 | ]; |
65 | 65 | |
66 | 66 | $this->tokenRefreshHeaders = $this->tokenExchangeHeaders; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | $data = new Data\Collection($response); |
77 | 77 | |
78 | - if (!$data->exists('sub')) { |
|
78 | + if ( ! $data->exists('sub')) { |
|
79 | 79 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
80 | 80 | } |
81 | 81 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | $profileImages = $data->get('profile_images'); |
95 | 95 | if ($this->config->get('photo_size')) { |
96 | - $prop = 'image' . $this->config->get('photo_size'); |
|
96 | + $prop = 'image'.$this->config->get('photo_size'); |
|
97 | 97 | } else { |
98 | 98 | $prop = 'image192'; |
99 | 99 | } |
@@ -35,116 +35,116 @@ |
||
35 | 35 | */ |
36 | 36 | class Steam extends OpenID |
37 | 37 | { |
38 | - /** |
|
39 | - * {@inheritdoc} |
|
40 | - */ |
|
41 | - protected $openidIdentifier = 'http://steamcommunity.com/openid'; |
|
42 | - |
|
43 | - /** |
|
44 | - * {@inheritdoc} |
|
45 | - */ |
|
46 | - protected $apiDocumentation = 'https://steamcommunity.com/dev'; |
|
47 | - |
|
48 | - /** |
|
49 | - * {@inheritdoc} |
|
50 | - */ |
|
51 | - public function authenticateFinish() |
|
52 | - { |
|
53 | - parent::authenticateFinish(); |
|
54 | - |
|
55 | - $userProfile = $this->storage->get($this->providerId . '.user'); |
|
56 | - |
|
57 | - $userProfile->identifier = str_ireplace([ |
|
58 | - 'http://steamcommunity.com/openid/id/', |
|
59 | - 'https://steamcommunity.com/openid/id/', |
|
60 | - ], '', $userProfile->identifier); |
|
61 | - |
|
62 | - if (!$userProfile->identifier) { |
|
63 | - throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
64 | - } |
|
65 | - |
|
66 | - try { |
|
67 | - $apiKey = $this->config->filter('keys')->get('secret'); |
|
68 | - |
|
69 | - // if api key is provided, we attempt to use steam web api |
|
70 | - if ($apiKey) { |
|
71 | - $result = $this->getUserProfileWebAPI($apiKey, $userProfile->identifier); |
|
72 | - } else { |
|
73 | - // otherwise we fallback to community data |
|
74 | - $result = $this->getUserProfileLegacyAPI($userProfile->identifier); |
|
75 | - } |
|
76 | - |
|
77 | - // fetch user profile |
|
78 | - foreach ($result as $k => $v) { |
|
79 | - $userProfile->$k = $v ?: $userProfile->$k; |
|
80 | - } |
|
81 | - } catch (\Exception $e) { |
|
82 | - } |
|
83 | - |
|
84 | - // store user profile |
|
85 | - $this->storage->set($this->providerId . '.user', $userProfile); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Fetch user profile on Steam web API |
|
90 | - * |
|
91 | - * @param $apiKey |
|
92 | - * @param $steam64 |
|
93 | - * |
|
94 | - * @return array |
|
95 | - */ |
|
96 | - public function getUserProfileWebAPI($apiKey, $steam64) |
|
97 | - { |
|
98 | - $q = http_build_query(['key' => $apiKey, 'steamids' => $steam64]); |
|
99 | - $apiUrl = 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?' . $q; |
|
100 | - |
|
101 | - $response = $this->httpClient->request($apiUrl); |
|
102 | - |
|
103 | - $data = json_decode($response); |
|
104 | - |
|
105 | - $data = isset($data->response->players[0]) ? $data->response->players[0] : null; |
|
106 | - |
|
107 | - $data = new Data\Collection($data); |
|
108 | - |
|
109 | - $userProfile = []; |
|
110 | - |
|
111 | - $userProfile['displayName'] = (string)$data->get('personaname'); |
|
112 | - $userProfile['firstName'] = (string)$data->get('realname'); |
|
113 | - $userProfile['photoURL'] = (string)$data->get('avatarfull'); |
|
114 | - $userProfile['profileURL'] = (string)$data->get('profileurl'); |
|
115 | - $userProfile['country'] = (string)$data->get('loccountrycode'); |
|
116 | - |
|
117 | - return $userProfile; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Fetch user profile on community API |
|
122 | - * @param $steam64 |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function getUserProfileLegacyAPI($steam64) |
|
126 | - { |
|
127 | - libxml_use_internal_errors(false); |
|
128 | - |
|
129 | - $apiUrl = 'http://steamcommunity.com/profiles/' . $steam64 . '/?xml=1'; |
|
130 | - |
|
131 | - $response = $this->httpClient->request($apiUrl); |
|
132 | - |
|
133 | - $data = new \SimpleXMLElement($response); |
|
134 | - |
|
135 | - $data = new Data\Collection($data); |
|
136 | - |
|
137 | - $userProfile = []; |
|
138 | - |
|
139 | - $userProfile['displayName'] = (string)$data->get('steamID'); |
|
140 | - $userProfile['firstName'] = (string)$data->get('realname'); |
|
141 | - $userProfile['photoURL'] = (string)$data->get('avatarFull'); |
|
142 | - $userProfile['description'] = (string)$data->get('summary'); |
|
143 | - $userProfile['region'] = (string)$data->get('location'); |
|
144 | - $userProfile['profileURL'] = (string)$data->get('customURL') |
|
145 | - ? 'http://steamcommunity.com/id/' . (string)$data->get('customURL') |
|
146 | - : 'http://steamcommunity.com/profiles/' . $steam64; |
|
147 | - |
|
148 | - return $userProfile; |
|
149 | - } |
|
38 | + /** |
|
39 | + * {@inheritdoc} |
|
40 | + */ |
|
41 | + protected $openidIdentifier = 'http://steamcommunity.com/openid'; |
|
42 | + |
|
43 | + /** |
|
44 | + * {@inheritdoc} |
|
45 | + */ |
|
46 | + protected $apiDocumentation = 'https://steamcommunity.com/dev'; |
|
47 | + |
|
48 | + /** |
|
49 | + * {@inheritdoc} |
|
50 | + */ |
|
51 | + public function authenticateFinish() |
|
52 | + { |
|
53 | + parent::authenticateFinish(); |
|
54 | + |
|
55 | + $userProfile = $this->storage->get($this->providerId . '.user'); |
|
56 | + |
|
57 | + $userProfile->identifier = str_ireplace([ |
|
58 | + 'http://steamcommunity.com/openid/id/', |
|
59 | + 'https://steamcommunity.com/openid/id/', |
|
60 | + ], '', $userProfile->identifier); |
|
61 | + |
|
62 | + if (!$userProfile->identifier) { |
|
63 | + throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
64 | + } |
|
65 | + |
|
66 | + try { |
|
67 | + $apiKey = $this->config->filter('keys')->get('secret'); |
|
68 | + |
|
69 | + // if api key is provided, we attempt to use steam web api |
|
70 | + if ($apiKey) { |
|
71 | + $result = $this->getUserProfileWebAPI($apiKey, $userProfile->identifier); |
|
72 | + } else { |
|
73 | + // otherwise we fallback to community data |
|
74 | + $result = $this->getUserProfileLegacyAPI($userProfile->identifier); |
|
75 | + } |
|
76 | + |
|
77 | + // fetch user profile |
|
78 | + foreach ($result as $k => $v) { |
|
79 | + $userProfile->$k = $v ?: $userProfile->$k; |
|
80 | + } |
|
81 | + } catch (\Exception $e) { |
|
82 | + } |
|
83 | + |
|
84 | + // store user profile |
|
85 | + $this->storage->set($this->providerId . '.user', $userProfile); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Fetch user profile on Steam web API |
|
90 | + * |
|
91 | + * @param $apiKey |
|
92 | + * @param $steam64 |
|
93 | + * |
|
94 | + * @return array |
|
95 | + */ |
|
96 | + public function getUserProfileWebAPI($apiKey, $steam64) |
|
97 | + { |
|
98 | + $q = http_build_query(['key' => $apiKey, 'steamids' => $steam64]); |
|
99 | + $apiUrl = 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?' . $q; |
|
100 | + |
|
101 | + $response = $this->httpClient->request($apiUrl); |
|
102 | + |
|
103 | + $data = json_decode($response); |
|
104 | + |
|
105 | + $data = isset($data->response->players[0]) ? $data->response->players[0] : null; |
|
106 | + |
|
107 | + $data = new Data\Collection($data); |
|
108 | + |
|
109 | + $userProfile = []; |
|
110 | + |
|
111 | + $userProfile['displayName'] = (string)$data->get('personaname'); |
|
112 | + $userProfile['firstName'] = (string)$data->get('realname'); |
|
113 | + $userProfile['photoURL'] = (string)$data->get('avatarfull'); |
|
114 | + $userProfile['profileURL'] = (string)$data->get('profileurl'); |
|
115 | + $userProfile['country'] = (string)$data->get('loccountrycode'); |
|
116 | + |
|
117 | + return $userProfile; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Fetch user profile on community API |
|
122 | + * @param $steam64 |
|
123 | + * @return array |
|
124 | + */ |
|
125 | + public function getUserProfileLegacyAPI($steam64) |
|
126 | + { |
|
127 | + libxml_use_internal_errors(false); |
|
128 | + |
|
129 | + $apiUrl = 'http://steamcommunity.com/profiles/' . $steam64 . '/?xml=1'; |
|
130 | + |
|
131 | + $response = $this->httpClient->request($apiUrl); |
|
132 | + |
|
133 | + $data = new \SimpleXMLElement($response); |
|
134 | + |
|
135 | + $data = new Data\Collection($data); |
|
136 | + |
|
137 | + $userProfile = []; |
|
138 | + |
|
139 | + $userProfile['displayName'] = (string)$data->get('steamID'); |
|
140 | + $userProfile['firstName'] = (string)$data->get('realname'); |
|
141 | + $userProfile['photoURL'] = (string)$data->get('avatarFull'); |
|
142 | + $userProfile['description'] = (string)$data->get('summary'); |
|
143 | + $userProfile['region'] = (string)$data->get('location'); |
|
144 | + $userProfile['profileURL'] = (string)$data->get('customURL') |
|
145 | + ? 'http://steamcommunity.com/id/' . (string)$data->get('customURL') |
|
146 | + : 'http://steamcommunity.com/profiles/' . $steam64; |
|
147 | + |
|
148 | + return $userProfile; |
|
149 | + } |
|
150 | 150 | } |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | { |
53 | 53 | parent::authenticateFinish(); |
54 | 54 | |
55 | - $userProfile = $this->storage->get($this->providerId . '.user'); |
|
55 | + $userProfile = $this->storage->get($this->providerId.'.user'); |
|
56 | 56 | |
57 | 57 | $userProfile->identifier = str_ireplace([ |
58 | 58 | 'http://steamcommunity.com/openid/id/', |
59 | 59 | 'https://steamcommunity.com/openid/id/', |
60 | 60 | ], '', $userProfile->identifier); |
61 | 61 | |
62 | - if (!$userProfile->identifier) { |
|
62 | + if ( ! $userProfile->identifier) { |
|
63 | 63 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
64 | 64 | } |
65 | 65 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | // store user profile |
85 | - $this->storage->set($this->providerId . '.user', $userProfile); |
|
85 | + $this->storage->set($this->providerId.'.user', $userProfile); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public function getUserProfileWebAPI($apiKey, $steam64) |
97 | 97 | { |
98 | 98 | $q = http_build_query(['key' => $apiKey, 'steamids' => $steam64]); |
99 | - $apiUrl = 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?' . $q; |
|
99 | + $apiUrl = 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?'.$q; |
|
100 | 100 | |
101 | 101 | $response = $this->httpClient->request($apiUrl); |
102 | 102 | |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | |
109 | 109 | $userProfile = []; |
110 | 110 | |
111 | - $userProfile['displayName'] = (string)$data->get('personaname'); |
|
112 | - $userProfile['firstName'] = (string)$data->get('realname'); |
|
113 | - $userProfile['photoURL'] = (string)$data->get('avatarfull'); |
|
114 | - $userProfile['profileURL'] = (string)$data->get('profileurl'); |
|
115 | - $userProfile['country'] = (string)$data->get('loccountrycode'); |
|
111 | + $userProfile['displayName'] = (string) $data->get('personaname'); |
|
112 | + $userProfile['firstName'] = (string) $data->get('realname'); |
|
113 | + $userProfile['photoURL'] = (string) $data->get('avatarfull'); |
|
114 | + $userProfile['profileURL'] = (string) $data->get('profileurl'); |
|
115 | + $userProfile['country'] = (string) $data->get('loccountrycode'); |
|
116 | 116 | |
117 | 117 | return $userProfile; |
118 | 118 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | { |
127 | 127 | libxml_use_internal_errors(false); |
128 | 128 | |
129 | - $apiUrl = 'http://steamcommunity.com/profiles/' . $steam64 . '/?xml=1'; |
|
129 | + $apiUrl = 'http://steamcommunity.com/profiles/'.$steam64.'/?xml=1'; |
|
130 | 130 | |
131 | 131 | $response = $this->httpClient->request($apiUrl); |
132 | 132 | |
@@ -136,14 +136,14 @@ discard block |
||
136 | 136 | |
137 | 137 | $userProfile = []; |
138 | 138 | |
139 | - $userProfile['displayName'] = (string)$data->get('steamID'); |
|
140 | - $userProfile['firstName'] = (string)$data->get('realname'); |
|
141 | - $userProfile['photoURL'] = (string)$data->get('avatarFull'); |
|
142 | - $userProfile['description'] = (string)$data->get('summary'); |
|
143 | - $userProfile['region'] = (string)$data->get('location'); |
|
144 | - $userProfile['profileURL'] = (string)$data->get('customURL') |
|
145 | - ? 'http://steamcommunity.com/id/' . (string)$data->get('customURL') |
|
146 | - : 'http://steamcommunity.com/profiles/' . $steam64; |
|
139 | + $userProfile['displayName'] = (string) $data->get('steamID'); |
|
140 | + $userProfile['firstName'] = (string) $data->get('realname'); |
|
141 | + $userProfile['photoURL'] = (string) $data->get('avatarFull'); |
|
142 | + $userProfile['description'] = (string) $data->get('summary'); |
|
143 | + $userProfile['region'] = (string) $data->get('location'); |
|
144 | + $userProfile['profileURL'] = (string) $data->get('customURL') |
|
145 | + ? 'http://steamcommunity.com/id/'.(string) $data->get('customURL') |
|
146 | + : 'http://steamcommunity.com/profiles/'.$steam64; |
|
147 | 147 | |
148 | 148 | return $userProfile; |
149 | 149 | } |
@@ -17,75 +17,75 @@ |
||
17 | 17 | */ |
18 | 18 | class DeviantArt extends OAuth2 |
19 | 19 | { |
20 | - /** |
|
21 | - * {@inheritdoc} |
|
22 | - */ |
|
23 | - protected $scope = 'user'; |
|
20 | + /** |
|
21 | + * {@inheritdoc} |
|
22 | + */ |
|
23 | + protected $scope = 'user'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * {@inheritdoc} |
|
27 | - */ |
|
28 | - protected $apiBaseUrl = 'https://www.deviantart.com/api/v1/oauth2/'; |
|
25 | + /** |
|
26 | + * {@inheritdoc} |
|
27 | + */ |
|
28 | + protected $apiBaseUrl = 'https://www.deviantart.com/api/v1/oauth2/'; |
|
29 | 29 | |
30 | - /** |
|
31 | - * {@inheritdoc} |
|
32 | - */ |
|
33 | - protected $authorizeUrl = 'https://www.deviantart.com/oauth2/authorize'; |
|
30 | + /** |
|
31 | + * {@inheritdoc} |
|
32 | + */ |
|
33 | + protected $authorizeUrl = 'https://www.deviantart.com/oauth2/authorize'; |
|
34 | 34 | |
35 | - /** |
|
36 | - * {@inheritdoc} |
|
37 | - */ |
|
38 | - protected $accessTokenUrl = 'https://www.deviantart.com/oauth2/token'; |
|
35 | + /** |
|
36 | + * {@inheritdoc} |
|
37 | + */ |
|
38 | + protected $accessTokenUrl = 'https://www.deviantart.com/oauth2/token'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * {@inheritdoc} |
|
42 | - */ |
|
43 | - protected $apiDocumentation = 'https://www.deviantart.com/developers/http/v1/20200519'; |
|
40 | + /** |
|
41 | + * {@inheritdoc} |
|
42 | + */ |
|
43 | + protected $apiDocumentation = 'https://www.deviantart.com/developers/http/v1/20200519'; |
|
44 | 44 | |
45 | - /** |
|
46 | - * {@inheritdoc} |
|
47 | - */ |
|
48 | - protected function initialize() |
|
49 | - { |
|
50 | - parent::initialize(); |
|
45 | + /** |
|
46 | + * {@inheritdoc} |
|
47 | + */ |
|
48 | + protected function initialize() |
|
49 | + { |
|
50 | + parent::initialize(); |
|
51 | 51 | |
52 | - if ($this->isRefreshTokenAvailable()) { |
|
53 | - $this->tokenRefreshParameters += [ |
|
54 | - 'client_id' => $this->clientId, |
|
55 | - 'client_secret' => $this->clientSecret, |
|
56 | - ]; |
|
57 | - } |
|
58 | - } |
|
52 | + if ($this->isRefreshTokenAvailable()) { |
|
53 | + $this->tokenRefreshParameters += [ |
|
54 | + 'client_id' => $this->clientId, |
|
55 | + 'client_secret' => $this->clientSecret, |
|
56 | + ]; |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * {@inheritdoc} |
|
62 | - * |
|
63 | - * See: https://www.deviantart.com/developers/http/v1/20200519/user_whoami/2413749853e66c5812c9beccc0ab3495 |
|
64 | - */ |
|
65 | - public function getUserProfile() |
|
66 | - { |
|
67 | - $response = $this->apiRequest('user/whoami'); |
|
60 | + /** |
|
61 | + * {@inheritdoc} |
|
62 | + * |
|
63 | + * See: https://www.deviantart.com/developers/http/v1/20200519/user_whoami/2413749853e66c5812c9beccc0ab3495 |
|
64 | + */ |
|
65 | + public function getUserProfile() |
|
66 | + { |
|
67 | + $response = $this->apiRequest('user/whoami'); |
|
68 | 68 | |
69 | - $data = new Data\Collection($response); |
|
69 | + $data = new Data\Collection($response); |
|
70 | 70 | |
71 | - $userProfile = new User\Profile(); |
|
71 | + $userProfile = new User\Profile(); |
|
72 | 72 | |
73 | - $full_name = explode(' ', $data->filter('profile')->get('real_name')); |
|
74 | - if (count($full_name) < 2) { |
|
75 | - $full_name[1] = ''; |
|
76 | - } |
|
73 | + $full_name = explode(' ', $data->filter('profile')->get('real_name')); |
|
74 | + if (count($full_name) < 2) { |
|
75 | + $full_name[1] = ''; |
|
76 | + } |
|
77 | 77 | |
78 | - $userProfile->identifier = $data->get('userid'); |
|
79 | - $userProfile->displayName = $data->get('username'); |
|
80 | - $userProfile->profileURL = $data->get('usericon'); |
|
81 | - $userProfile->webSiteURL = $data->filter('profile')->get('website'); |
|
82 | - $userProfile->firstName = $full_name[0]; |
|
83 | - $userProfile->lastName = $full_name[1]; |
|
84 | - $userProfile->profileURL = $data->filter('profile')->filter('profile_pic')->get('url'); |
|
85 | - $userProfile->gender = $data->filter('details')->get('sex'); |
|
86 | - $userProfile->age = $data->filter('details')->get('age'); |
|
87 | - $userProfile->country = $data->filter('geo')->get('country'); |
|
78 | + $userProfile->identifier = $data->get('userid'); |
|
79 | + $userProfile->displayName = $data->get('username'); |
|
80 | + $userProfile->profileURL = $data->get('usericon'); |
|
81 | + $userProfile->webSiteURL = $data->filter('profile')->get('website'); |
|
82 | + $userProfile->firstName = $full_name[0]; |
|
83 | + $userProfile->lastName = $full_name[1]; |
|
84 | + $userProfile->profileURL = $data->filter('profile')->filter('profile_pic')->get('url'); |
|
85 | + $userProfile->gender = $data->filter('details')->get('sex'); |
|
86 | + $userProfile->age = $data->filter('details')->get('age'); |
|
87 | + $userProfile->country = $data->filter('geo')->get('country'); |
|
88 | 88 | |
89 | - return $userProfile; |
|
90 | - } |
|
89 | + return $userProfile; |
|
90 | + } |
|
91 | 91 | } |
@@ -17,87 +17,87 @@ |
||
17 | 17 | */ |
18 | 18 | class WindowsLive extends OAuth2 |
19 | 19 | { |
20 | - /** |
|
21 | - * {@inheritdoc} |
|
22 | - */ |
|
23 | - protected $scope = 'wl.basic wl.contacts_emails wl.emails wl.signin wl.share wl.birthday'; |
|
24 | - |
|
25 | - /** |
|
26 | - * {@inheritdoc} |
|
27 | - */ |
|
28 | - protected $apiBaseUrl = 'https://apis.live.net/v5.0/'; |
|
29 | - |
|
30 | - /** |
|
31 | - * {@inheritdoc} |
|
32 | - */ |
|
33 | - protected $authorizeUrl = 'https://login.live.com/oauth20_authorize.srf'; |
|
34 | - |
|
35 | - /** |
|
36 | - * {@inheritdoc} |
|
37 | - */ |
|
38 | - protected $accessTokenUrl = 'https://login.live.com/oauth20_token.srf'; |
|
39 | - |
|
40 | - /** |
|
41 | - * {@inheritdoc} |
|
42 | - */ |
|
43 | - protected $apiDocumentation = 'https://msdn.microsoft.com/en-us/library/hh243647.aspx'; |
|
44 | - |
|
45 | - /** |
|
46 | - * {@inheritdoc} |
|
47 | - */ |
|
48 | - public function getUserProfile() |
|
49 | - { |
|
50 | - $response = $this->apiRequest('me'); |
|
51 | - |
|
52 | - $data = new Data\Collection($response); |
|
53 | - |
|
54 | - if (!$data->exists('id')) { |
|
55 | - throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
56 | - } |
|
57 | - |
|
58 | - $userProfile = new User\Profile(); |
|
59 | - |
|
60 | - $userProfile->identifier = $data->get('id'); |
|
61 | - $userProfile->displayName = $data->get('name'); |
|
62 | - $userProfile->firstName = $data->get('first_name'); |
|
63 | - $userProfile->lastName = $data->get('last_name'); |
|
64 | - $userProfile->gender = $data->get('gender'); |
|
65 | - $userProfile->profileURL = $data->get('link'); |
|
66 | - $userProfile->email = $data->filter('emails')->get('preferred'); |
|
67 | - $userProfile->emailVerified = $data->filter('emails')->get('account'); |
|
68 | - $userProfile->birthDay = $data->get('birth_day'); |
|
69 | - $userProfile->birthMonth = $data->get('birth_month'); |
|
70 | - $userProfile->birthYear = $data->get('birth_year'); |
|
71 | - $userProfile->language = $data->get('locale'); |
|
72 | - |
|
73 | - return $userProfile; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * {@inheritdoc} |
|
78 | - */ |
|
79 | - public function getUserContacts() |
|
80 | - { |
|
81 | - $response = $this->apiRequest('me/contacts'); |
|
82 | - |
|
83 | - $data = new Data\Collection($response); |
|
84 | - |
|
85 | - if (!$data->exists('data')) { |
|
86 | - throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
87 | - } |
|
88 | - |
|
89 | - $contacts = []; |
|
90 | - |
|
91 | - foreach ($data->filter('data')->toArray() as $idx => $entry) { |
|
92 | - $userContact = new User\Contact(); |
|
93 | - |
|
94 | - $userContact->identifier = $entry->get('id'); |
|
95 | - $userContact->displayName = $entry->get('name'); |
|
96 | - $userContact->email = $entry->filter('emails')->get('preferred'); |
|
97 | - |
|
98 | - $contacts[] = $userContact; |
|
99 | - } |
|
100 | - |
|
101 | - return $contacts; |
|
102 | - } |
|
20 | + /** |
|
21 | + * {@inheritdoc} |
|
22 | + */ |
|
23 | + protected $scope = 'wl.basic wl.contacts_emails wl.emails wl.signin wl.share wl.birthday'; |
|
24 | + |
|
25 | + /** |
|
26 | + * {@inheritdoc} |
|
27 | + */ |
|
28 | + protected $apiBaseUrl = 'https://apis.live.net/v5.0/'; |
|
29 | + |
|
30 | + /** |
|
31 | + * {@inheritdoc} |
|
32 | + */ |
|
33 | + protected $authorizeUrl = 'https://login.live.com/oauth20_authorize.srf'; |
|
34 | + |
|
35 | + /** |
|
36 | + * {@inheritdoc} |
|
37 | + */ |
|
38 | + protected $accessTokenUrl = 'https://login.live.com/oauth20_token.srf'; |
|
39 | + |
|
40 | + /** |
|
41 | + * {@inheritdoc} |
|
42 | + */ |
|
43 | + protected $apiDocumentation = 'https://msdn.microsoft.com/en-us/library/hh243647.aspx'; |
|
44 | + |
|
45 | + /** |
|
46 | + * {@inheritdoc} |
|
47 | + */ |
|
48 | + public function getUserProfile() |
|
49 | + { |
|
50 | + $response = $this->apiRequest('me'); |
|
51 | + |
|
52 | + $data = new Data\Collection($response); |
|
53 | + |
|
54 | + if (!$data->exists('id')) { |
|
55 | + throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
56 | + } |
|
57 | + |
|
58 | + $userProfile = new User\Profile(); |
|
59 | + |
|
60 | + $userProfile->identifier = $data->get('id'); |
|
61 | + $userProfile->displayName = $data->get('name'); |
|
62 | + $userProfile->firstName = $data->get('first_name'); |
|
63 | + $userProfile->lastName = $data->get('last_name'); |
|
64 | + $userProfile->gender = $data->get('gender'); |
|
65 | + $userProfile->profileURL = $data->get('link'); |
|
66 | + $userProfile->email = $data->filter('emails')->get('preferred'); |
|
67 | + $userProfile->emailVerified = $data->filter('emails')->get('account'); |
|
68 | + $userProfile->birthDay = $data->get('birth_day'); |
|
69 | + $userProfile->birthMonth = $data->get('birth_month'); |
|
70 | + $userProfile->birthYear = $data->get('birth_year'); |
|
71 | + $userProfile->language = $data->get('locale'); |
|
72 | + |
|
73 | + return $userProfile; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * {@inheritdoc} |
|
78 | + */ |
|
79 | + public function getUserContacts() |
|
80 | + { |
|
81 | + $response = $this->apiRequest('me/contacts'); |
|
82 | + |
|
83 | + $data = new Data\Collection($response); |
|
84 | + |
|
85 | + if (!$data->exists('data')) { |
|
86 | + throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
87 | + } |
|
88 | + |
|
89 | + $contacts = []; |
|
90 | + |
|
91 | + foreach ($data->filter('data')->toArray() as $idx => $entry) { |
|
92 | + $userContact = new User\Contact(); |
|
93 | + |
|
94 | + $userContact->identifier = $entry->get('id'); |
|
95 | + $userContact->displayName = $entry->get('name'); |
|
96 | + $userContact->email = $entry->filter('emails')->get('preferred'); |
|
97 | + |
|
98 | + $contacts[] = $userContact; |
|
99 | + } |
|
100 | + |
|
101 | + return $contacts; |
|
102 | + } |
|
103 | 103 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | $data = new Data\Collection($response); |
53 | 53 | |
54 | - if (!$data->exists('id')) { |
|
54 | + if ( ! $data->exists('id')) { |
|
55 | 55 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
56 | 56 | } |
57 | 57 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | $data = new Data\Collection($response); |
84 | 84 | |
85 | - if (!$data->exists('data')) { |
|
85 | + if ( ! $data->exists('data')) { |
|
86 | 86 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
87 | 87 | } |
88 | 88 |
@@ -17,72 +17,72 @@ |
||
17 | 17 | */ |
18 | 18 | class Disqus extends OAuth2 |
19 | 19 | { |
20 | - /** |
|
21 | - * {@inheritdoc} |
|
22 | - */ |
|
23 | - protected $scope = 'read,email'; |
|
24 | - |
|
25 | - /** |
|
26 | - * {@inheritdoc} |
|
27 | - */ |
|
28 | - protected $apiBaseUrl = 'https://disqus.com/api/3.0/'; |
|
29 | - |
|
30 | - /** |
|
31 | - * {@inheritdoc} |
|
32 | - */ |
|
33 | - protected $authorizeUrl = 'https://disqus.com/api/oauth/2.0/authorize'; |
|
34 | - |
|
35 | - /** |
|
36 | - * {@inheritdoc} |
|
37 | - */ |
|
38 | - protected $accessTokenUrl = 'https://disqus.com/api/oauth/2.0/access_token/'; |
|
39 | - |
|
40 | - /** |
|
41 | - * {@inheritdoc} |
|
42 | - */ |
|
43 | - protected $apiDocumentation = 'https://disqus.com/api/docs/auth/'; |
|
44 | - |
|
45 | - /** |
|
46 | - * {@inheritdoc} |
|
47 | - */ |
|
48 | - protected function initialize() |
|
49 | - { |
|
50 | - parent::initialize(); |
|
51 | - |
|
52 | - $this->apiRequestParameters = [ |
|
53 | - 'api_key' => $this->clientId, 'api_secret' => $this->clientSecret |
|
54 | - ]; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * {@inheritdoc} |
|
59 | - */ |
|
60 | - public function getUserProfile() |
|
61 | - { |
|
62 | - $response = $this->apiRequest('users/details'); |
|
63 | - |
|
64 | - $data = new Data\Collection($response); |
|
65 | - |
|
66 | - if (!$data->filter('response')->exists('id')) { |
|
67 | - throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
68 | - } |
|
69 | - |
|
70 | - $userProfile = new User\Profile(); |
|
71 | - |
|
72 | - $data = $data->filter('response'); |
|
73 | - |
|
74 | - $userProfile->identifier = $data->get('id'); |
|
75 | - $userProfile->displayName = $data->get('name'); |
|
76 | - $userProfile->description = $data->get('bio'); |
|
77 | - $userProfile->profileURL = $data->get('profileUrl'); |
|
78 | - $userProfile->email = $data->get('email'); |
|
79 | - $userProfile->region = $data->get('location'); |
|
80 | - $userProfile->description = $data->get('about'); |
|
81 | - |
|
82 | - $userProfile->photoURL = $data->filter('avatar')->get('permalink'); |
|
83 | - |
|
84 | - $userProfile->displayName = $userProfile->displayName ?: $data->get('username'); |
|
85 | - |
|
86 | - return $userProfile; |
|
87 | - } |
|
20 | + /** |
|
21 | + * {@inheritdoc} |
|
22 | + */ |
|
23 | + protected $scope = 'read,email'; |
|
24 | + |
|
25 | + /** |
|
26 | + * {@inheritdoc} |
|
27 | + */ |
|
28 | + protected $apiBaseUrl = 'https://disqus.com/api/3.0/'; |
|
29 | + |
|
30 | + /** |
|
31 | + * {@inheritdoc} |
|
32 | + */ |
|
33 | + protected $authorizeUrl = 'https://disqus.com/api/oauth/2.0/authorize'; |
|
34 | + |
|
35 | + /** |
|
36 | + * {@inheritdoc} |
|
37 | + */ |
|
38 | + protected $accessTokenUrl = 'https://disqus.com/api/oauth/2.0/access_token/'; |
|
39 | + |
|
40 | + /** |
|
41 | + * {@inheritdoc} |
|
42 | + */ |
|
43 | + protected $apiDocumentation = 'https://disqus.com/api/docs/auth/'; |
|
44 | + |
|
45 | + /** |
|
46 | + * {@inheritdoc} |
|
47 | + */ |
|
48 | + protected function initialize() |
|
49 | + { |
|
50 | + parent::initialize(); |
|
51 | + |
|
52 | + $this->apiRequestParameters = [ |
|
53 | + 'api_key' => $this->clientId, 'api_secret' => $this->clientSecret |
|
54 | + ]; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * {@inheritdoc} |
|
59 | + */ |
|
60 | + public function getUserProfile() |
|
61 | + { |
|
62 | + $response = $this->apiRequest('users/details'); |
|
63 | + |
|
64 | + $data = new Data\Collection($response); |
|
65 | + |
|
66 | + if (!$data->filter('response')->exists('id')) { |
|
67 | + throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
68 | + } |
|
69 | + |
|
70 | + $userProfile = new User\Profile(); |
|
71 | + |
|
72 | + $data = $data->filter('response'); |
|
73 | + |
|
74 | + $userProfile->identifier = $data->get('id'); |
|
75 | + $userProfile->displayName = $data->get('name'); |
|
76 | + $userProfile->description = $data->get('bio'); |
|
77 | + $userProfile->profileURL = $data->get('profileUrl'); |
|
78 | + $userProfile->email = $data->get('email'); |
|
79 | + $userProfile->region = $data->get('location'); |
|
80 | + $userProfile->description = $data->get('about'); |
|
81 | + |
|
82 | + $userProfile->photoURL = $data->filter('avatar')->get('permalink'); |
|
83 | + |
|
84 | + $userProfile->displayName = $userProfile->displayName ?: $data->get('username'); |
|
85 | + |
|
86 | + return $userProfile; |
|
87 | + } |
|
88 | 88 | } |
@@ -63,7 +63,7 @@ |
||
63 | 63 | |
64 | 64 | $data = new Data\Collection($response); |
65 | 65 | |
66 | - if (!$data->filter('response')->exists('id')) { |
|
66 | + if ( ! $data->filter('response')->exists('id')) { |
|
67 | 67 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
68 | 68 | } |
69 | 69 |
@@ -15,57 +15,57 @@ |
||
15 | 15 | */ |
16 | 16 | class PaypalOpenID extends OpenID |
17 | 17 | { |
18 | - /** |
|
19 | - * {@inheritdoc} |
|
20 | - */ |
|
21 | - protected $openidIdentifier = 'https://www.sandbox.paypal.com/webapps/auth/server'; |
|
18 | + /** |
|
19 | + * {@inheritdoc} |
|
20 | + */ |
|
21 | + protected $openidIdentifier = 'https://www.sandbox.paypal.com/webapps/auth/server'; |
|
22 | 22 | |
23 | - /** |
|
24 | - * {@inheritdoc} |
|
25 | - */ |
|
26 | - protected $apiDocumentation = 'https://developer.paypal.com/docs/connect-with-paypal/'; |
|
23 | + /** |
|
24 | + * {@inheritdoc} |
|
25 | + */ |
|
26 | + protected $apiDocumentation = 'https://developer.paypal.com/docs/connect-with-paypal/'; |
|
27 | 27 | |
28 | - /** |
|
29 | - * {@inheritdoc} |
|
30 | - */ |
|
31 | - public function authenticateBegin() |
|
32 | - { |
|
33 | - $this->openIdClient->identity = $this->openidIdentifier; |
|
34 | - $this->openIdClient->returnUrl = $this->callback; |
|
35 | - $this->openIdClient->required = [ |
|
36 | - 'namePerson/prefix', |
|
37 | - 'namePerson/first', |
|
38 | - 'namePerson/last', |
|
39 | - 'namePerson/middle', |
|
40 | - 'namePerson/suffix', |
|
41 | - 'namePerson/friendly', |
|
42 | - 'person/guid', |
|
43 | - 'birthDate/birthYear', |
|
44 | - 'birthDate/birthMonth', |
|
45 | - 'birthDate/birthday', |
|
46 | - 'gender', |
|
47 | - 'language/pref', |
|
48 | - 'contact/phone/default', |
|
49 | - 'contact/phone/home', |
|
50 | - 'contact/phone/business', |
|
51 | - 'contact/phone/cell', |
|
52 | - 'contact/phone/fax', |
|
53 | - 'contact/postaladdress/home', |
|
54 | - 'contact/postaladdressadditional/home', |
|
55 | - 'contact/city/home', |
|
56 | - 'contact/state/home', |
|
57 | - 'contact/country/home', |
|
58 | - 'contact/postalcode/home', |
|
59 | - 'contact/postaladdress/business', |
|
60 | - 'contact/postaladdressadditional/business', |
|
61 | - 'contact/city/business', |
|
62 | - 'contact/state/business', |
|
63 | - 'contact/country/business', |
|
64 | - 'contact/postalcode/business', |
|
65 | - 'company/name', |
|
66 | - 'company/title', |
|
67 | - ]; |
|
28 | + /** |
|
29 | + * {@inheritdoc} |
|
30 | + */ |
|
31 | + public function authenticateBegin() |
|
32 | + { |
|
33 | + $this->openIdClient->identity = $this->openidIdentifier; |
|
34 | + $this->openIdClient->returnUrl = $this->callback; |
|
35 | + $this->openIdClient->required = [ |
|
36 | + 'namePerson/prefix', |
|
37 | + 'namePerson/first', |
|
38 | + 'namePerson/last', |
|
39 | + 'namePerson/middle', |
|
40 | + 'namePerson/suffix', |
|
41 | + 'namePerson/friendly', |
|
42 | + 'person/guid', |
|
43 | + 'birthDate/birthYear', |
|
44 | + 'birthDate/birthMonth', |
|
45 | + 'birthDate/birthday', |
|
46 | + 'gender', |
|
47 | + 'language/pref', |
|
48 | + 'contact/phone/default', |
|
49 | + 'contact/phone/home', |
|
50 | + 'contact/phone/business', |
|
51 | + 'contact/phone/cell', |
|
52 | + 'contact/phone/fax', |
|
53 | + 'contact/postaladdress/home', |
|
54 | + 'contact/postaladdressadditional/home', |
|
55 | + 'contact/city/home', |
|
56 | + 'contact/state/home', |
|
57 | + 'contact/country/home', |
|
58 | + 'contact/postalcode/home', |
|
59 | + 'contact/postaladdress/business', |
|
60 | + 'contact/postaladdressadditional/business', |
|
61 | + 'contact/city/business', |
|
62 | + 'contact/state/business', |
|
63 | + 'contact/country/business', |
|
64 | + 'contact/postalcode/business', |
|
65 | + 'company/name', |
|
66 | + 'company/title', |
|
67 | + ]; |
|
68 | 68 | |
69 | - HttpClient\Util::redirect($this->openIdClient->authUrl()); |
|
70 | - } |
|
69 | + HttpClient\Util::redirect($this->openIdClient->authUrl()); |
|
70 | + } |
|
71 | 71 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | $data = new Data\Collection($response); |
105 | 105 | |
106 | - if (!$data->exists('sub')) { |
|
106 | + if ( ! $data->exists('sub')) { |
|
107 | 107 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
108 | 108 | } |
109 | 109 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $userProfile->emailVerified = $data->get('email_verified') ? $userProfile->email : ''; |
123 | 123 | |
124 | 124 | if ($this->config->get('photo_size')) { |
125 | - $userProfile->photoURL .= '?sz=' . $this->config->get('photo_size'); |
|
125 | + $userProfile->photoURL .= '?sz='.$this->config->get('photo_size'); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | return $userProfile; |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | protected function getGmailContacts($parameters = []) |
156 | 156 | { |
157 | 157 | $url = 'https://www.google.com/m8/feeds/contacts/default/full?' |
158 | - . http_build_query(array_replace(['alt' => 'json', 'v' => '3.0'], (array)$parameters)); |
|
158 | + . http_build_query(array_replace(['alt' => 'json', 'v' => '3.0'], (array) $parameters)); |
|
159 | 159 | |
160 | 160 | $response = $this->apiRequest($url); |
161 | 161 | |
162 | - if (!$response) { |
|
162 | + if ( ! $response) { |
|
163 | 163 | return []; |
164 | 164 | } |
165 | 165 | |
@@ -170,10 +170,10 @@ discard block |
||
170 | 170 | $uc = new User\Contact(); |
171 | 171 | |
172 | 172 | $uc->email = isset($entry->{'gd$email'}[0]->address) |
173 | - ? (string)$entry->{'gd$email'}[0]->address |
|
173 | + ? (string) $entry->{'gd$email'}[0]->address |
|
174 | 174 | : ''; |
175 | 175 | |
176 | - $uc->displayName = isset($entry->title->{'$t'}) ? (string)$entry->title->{'$t'} : ''; |
|
176 | + $uc->displayName = isset($entry->title->{'$t'}) ? (string) $entry->title->{'$t'} : ''; |
|
177 | 177 | $uc->identifier = ($uc->email != '') ? $uc->email : ''; |
178 | 178 | $uc->description = ''; |
179 | 179 |
@@ -46,155 +46,155 @@ |
||
46 | 46 | */ |
47 | 47 | class Google extends OAuth2 |
48 | 48 | { |
49 | - /** |
|
50 | - * {@inheritdoc} |
|
51 | - */ |
|
52 | - // phpcs:ignore |
|
53 | - protected $scope = 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'; |
|
54 | - |
|
55 | - /** |
|
56 | - * {@inheritdoc} |
|
57 | - */ |
|
58 | - protected $apiBaseUrl = 'https://www.googleapis.com/'; |
|
59 | - |
|
60 | - /** |
|
61 | - * {@inheritdoc} |
|
62 | - */ |
|
63 | - protected $authorizeUrl = 'https://accounts.google.com/o/oauth2/v2/auth'; |
|
64 | - |
|
65 | - /** |
|
66 | - * {@inheritdoc} |
|
67 | - */ |
|
68 | - protected $accessTokenUrl = 'https://oauth2.googleapis.com/token'; |
|
69 | - |
|
70 | - /** |
|
71 | - * {@inheritdoc} |
|
72 | - */ |
|
73 | - protected $apiDocumentation = 'https://developers.google.com/identity/protocols/OAuth2'; |
|
74 | - |
|
75 | - /** |
|
76 | - * {@inheritdoc} |
|
77 | - */ |
|
78 | - protected function initialize() |
|
79 | - { |
|
80 | - parent::initialize(); |
|
81 | - |
|
82 | - $this->AuthorizeUrlParameters += [ |
|
83 | - 'access_type' => 'offline', |
|
84 | - 'prompt' => 'consent' |
|
85 | - ]; |
|
86 | - |
|
87 | - if ($this->isRefreshTokenAvailable()) { |
|
88 | - $this->tokenRefreshParameters += [ |
|
89 | - 'client_id' => $this->clientId, |
|
90 | - 'client_secret' => $this->clientSecret, |
|
91 | - ]; |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * {@inheritdoc} |
|
97 | - * |
|
98 | - * See: https://developers.google.com/identity/protocols/OpenIDConnect#obtainuserinfo |
|
99 | - */ |
|
100 | - public function getUserProfile() |
|
101 | - { |
|
102 | - $response = $this->apiRequest('oauth2/v3/userinfo'); |
|
103 | - |
|
104 | - $data = new Data\Collection($response); |
|
105 | - |
|
106 | - if (!$data->exists('sub')) { |
|
107 | - throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
108 | - } |
|
109 | - |
|
110 | - $userProfile = new User\Profile(); |
|
111 | - |
|
112 | - $userProfile->identifier = $data->get('sub'); |
|
113 | - $userProfile->firstName = $data->get('given_name'); |
|
114 | - $userProfile->lastName = $data->get('family_name'); |
|
115 | - $userProfile->displayName = $data->get('name'); |
|
116 | - $userProfile->photoURL = $data->get('picture'); |
|
117 | - $userProfile->profileURL = $data->get('profile'); |
|
118 | - $userProfile->gender = $data->get('gender'); |
|
119 | - $userProfile->language = $data->get('locale'); |
|
120 | - $userProfile->email = $data->get('email'); |
|
121 | - |
|
122 | - $userProfile->emailVerified = $data->get('email_verified') ? $userProfile->email : ''; |
|
123 | - |
|
124 | - if ($this->config->get('photo_size')) { |
|
125 | - $userProfile->photoURL .= '?sz=' . $this->config->get('photo_size'); |
|
126 | - } |
|
127 | - |
|
128 | - return $userProfile; |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * {@inheritdoc} |
|
133 | - */ |
|
134 | - public function getUserContacts($parameters = []) |
|
135 | - { |
|
136 | - $parameters = ['max-results' => 500] + $parameters; |
|
137 | - |
|
138 | - // Google Gmail and Android contacts |
|
139 | - if (false !== strpos($this->scope, '/m8/feeds/') || false !== strpos($this->scope, '/auth/contacts.readonly')) { |
|
140 | - return $this->getGmailContacts($parameters); |
|
141 | - } |
|
142 | - |
|
143 | - return []; |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * Retrieve Gmail contacts |
|
148 | - * |
|
149 | - * @param array $parameters |
|
150 | - * |
|
151 | - * @return array |
|
152 | - * |
|
153 | - * @throws \Exception |
|
154 | - */ |
|
155 | - protected function getGmailContacts($parameters = []) |
|
156 | - { |
|
157 | - $url = 'https://www.google.com/m8/feeds/contacts/default/full?' |
|
158 | - . http_build_query(array_replace(['alt' => 'json', 'v' => '3.0'], (array)$parameters)); |
|
159 | - |
|
160 | - $response = $this->apiRequest($url); |
|
161 | - |
|
162 | - if (!$response) { |
|
163 | - return []; |
|
164 | - } |
|
165 | - |
|
166 | - $contacts = []; |
|
167 | - |
|
168 | - if (isset($response->feed->entry)) { |
|
169 | - foreach ($response->feed->entry as $idx => $entry) { |
|
170 | - $uc = new User\Contact(); |
|
171 | - |
|
172 | - $uc->email = isset($entry->{'gd$email'}[0]->address) |
|
173 | - ? (string)$entry->{'gd$email'}[0]->address |
|
174 | - : ''; |
|
175 | - |
|
176 | - $uc->displayName = isset($entry->title->{'$t'}) ? (string)$entry->title->{'$t'} : ''; |
|
177 | - $uc->identifier = ($uc->email != '') ? $uc->email : ''; |
|
178 | - $uc->description = ''; |
|
179 | - |
|
180 | - if (property_exists($response, 'website')) { |
|
181 | - if (is_array($response->website)) { |
|
182 | - foreach ($response->website as $w) { |
|
183 | - if ($w->primary == true) { |
|
184 | - $uc->webSiteURL = $w->value; |
|
185 | - } |
|
186 | - } |
|
187 | - } else { |
|
188 | - $uc->webSiteURL = $response->website->value; |
|
189 | - } |
|
190 | - } else { |
|
191 | - $uc->webSiteURL = ''; |
|
192 | - } |
|
193 | - |
|
194 | - $contacts[] = $uc; |
|
195 | - } |
|
196 | - } |
|
197 | - |
|
198 | - return $contacts; |
|
199 | - } |
|
49 | + /** |
|
50 | + * {@inheritdoc} |
|
51 | + */ |
|
52 | + // phpcs:ignore |
|
53 | + protected $scope = 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'; |
|
54 | + |
|
55 | + /** |
|
56 | + * {@inheritdoc} |
|
57 | + */ |
|
58 | + protected $apiBaseUrl = 'https://www.googleapis.com/'; |
|
59 | + |
|
60 | + /** |
|
61 | + * {@inheritdoc} |
|
62 | + */ |
|
63 | + protected $authorizeUrl = 'https://accounts.google.com/o/oauth2/v2/auth'; |
|
64 | + |
|
65 | + /** |
|
66 | + * {@inheritdoc} |
|
67 | + */ |
|
68 | + protected $accessTokenUrl = 'https://oauth2.googleapis.com/token'; |
|
69 | + |
|
70 | + /** |
|
71 | + * {@inheritdoc} |
|
72 | + */ |
|
73 | + protected $apiDocumentation = 'https://developers.google.com/identity/protocols/OAuth2'; |
|
74 | + |
|
75 | + /** |
|
76 | + * {@inheritdoc} |
|
77 | + */ |
|
78 | + protected function initialize() |
|
79 | + { |
|
80 | + parent::initialize(); |
|
81 | + |
|
82 | + $this->AuthorizeUrlParameters += [ |
|
83 | + 'access_type' => 'offline', |
|
84 | + 'prompt' => 'consent' |
|
85 | + ]; |
|
86 | + |
|
87 | + if ($this->isRefreshTokenAvailable()) { |
|
88 | + $this->tokenRefreshParameters += [ |
|
89 | + 'client_id' => $this->clientId, |
|
90 | + 'client_secret' => $this->clientSecret, |
|
91 | + ]; |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * {@inheritdoc} |
|
97 | + * |
|
98 | + * See: https://developers.google.com/identity/protocols/OpenIDConnect#obtainuserinfo |
|
99 | + */ |
|
100 | + public function getUserProfile() |
|
101 | + { |
|
102 | + $response = $this->apiRequest('oauth2/v3/userinfo'); |
|
103 | + |
|
104 | + $data = new Data\Collection($response); |
|
105 | + |
|
106 | + if (!$data->exists('sub')) { |
|
107 | + throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
|
108 | + } |
|
109 | + |
|
110 | + $userProfile = new User\Profile(); |
|
111 | + |
|
112 | + $userProfile->identifier = $data->get('sub'); |
|
113 | + $userProfile->firstName = $data->get('given_name'); |
|
114 | + $userProfile->lastName = $data->get('family_name'); |
|
115 | + $userProfile->displayName = $data->get('name'); |
|
116 | + $userProfile->photoURL = $data->get('picture'); |
|
117 | + $userProfile->profileURL = $data->get('profile'); |
|
118 | + $userProfile->gender = $data->get('gender'); |
|
119 | + $userProfile->language = $data->get('locale'); |
|
120 | + $userProfile->email = $data->get('email'); |
|
121 | + |
|
122 | + $userProfile->emailVerified = $data->get('email_verified') ? $userProfile->email : ''; |
|
123 | + |
|
124 | + if ($this->config->get('photo_size')) { |
|
125 | + $userProfile->photoURL .= '?sz=' . $this->config->get('photo_size'); |
|
126 | + } |
|
127 | + |
|
128 | + return $userProfile; |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * {@inheritdoc} |
|
133 | + */ |
|
134 | + public function getUserContacts($parameters = []) |
|
135 | + { |
|
136 | + $parameters = ['max-results' => 500] + $parameters; |
|
137 | + |
|
138 | + // Google Gmail and Android contacts |
|
139 | + if (false !== strpos($this->scope, '/m8/feeds/') || false !== strpos($this->scope, '/auth/contacts.readonly')) { |
|
140 | + return $this->getGmailContacts($parameters); |
|
141 | + } |
|
142 | + |
|
143 | + return []; |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * Retrieve Gmail contacts |
|
148 | + * |
|
149 | + * @param array $parameters |
|
150 | + * |
|
151 | + * @return array |
|
152 | + * |
|
153 | + * @throws \Exception |
|
154 | + */ |
|
155 | + protected function getGmailContacts($parameters = []) |
|
156 | + { |
|
157 | + $url = 'https://www.google.com/m8/feeds/contacts/default/full?' |
|
158 | + . http_build_query(array_replace(['alt' => 'json', 'v' => '3.0'], (array)$parameters)); |
|
159 | + |
|
160 | + $response = $this->apiRequest($url); |
|
161 | + |
|
162 | + if (!$response) { |
|
163 | + return []; |
|
164 | + } |
|
165 | + |
|
166 | + $contacts = []; |
|
167 | + |
|
168 | + if (isset($response->feed->entry)) { |
|
169 | + foreach ($response->feed->entry as $idx => $entry) { |
|
170 | + $uc = new User\Contact(); |
|
171 | + |
|
172 | + $uc->email = isset($entry->{'gd$email'}[0]->address) |
|
173 | + ? (string)$entry->{'gd$email'}[0]->address |
|
174 | + : ''; |
|
175 | + |
|
176 | + $uc->displayName = isset($entry->title->{'$t'}) ? (string)$entry->title->{'$t'} : ''; |
|
177 | + $uc->identifier = ($uc->email != '') ? $uc->email : ''; |
|
178 | + $uc->description = ''; |
|
179 | + |
|
180 | + if (property_exists($response, 'website')) { |
|
181 | + if (is_array($response->website)) { |
|
182 | + foreach ($response->website as $w) { |
|
183 | + if ($w->primary == true) { |
|
184 | + $uc->webSiteURL = $w->value; |
|
185 | + } |
|
186 | + } |
|
187 | + } else { |
|
188 | + $uc->webSiteURL = $response->website->value; |
|
189 | + } |
|
190 | + } else { |
|
191 | + $uc->webSiteURL = ''; |
|
192 | + } |
|
193 | + |
|
194 | + $contacts[] = $uc; |
|
195 | + } |
|
196 | + } |
|
197 | + |
|
198 | + return $contacts; |
|
199 | + } |
|
200 | 200 | } |