Blame view

common/components/nodge/eauth/src/services/extended/MailruOAuth2Service.php 976 Bytes
b0f143c3   Yarik   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  <?php
  /**
   * An example of extending the provider class.
   *
   * @author Maxim Zemskov <nodge@yandex.ru>
   * @link http://github.com/Nodge/yii2-eauth/
   * @license http://www.opensource.org/licenses/bsd-license.php
   */
  
  namespace nodge\eauth\services\extended;
  
  class MailruOAuth2Service extends \nodge\eauth\services\MailruOAuth2Service
  {
  
  	protected function fetchAttributes()
  	{
  		$tokenData = $this->getAccessTokenData();
  
  		$info = $this->makeSignedRequest('/', [
  			'query' => [
  				'uids' => $tokenData['params']['x_mailru_vid'],
  				'method' => 'users.getInfo',
  				'app_id' => $this->clientId,
  			],
  		]);
  
  		$info = $info[0];
  
  		$this->attributes['id'] = $info['uid'];
  		$this->attributes['name'] = $info['first_name'] . ' ' . $info['last_name'];
  		$this->attributes['first_name'] = $info['first_name'];
  		$this->attributes['last_name'] = $info['last_name'];
  		$this->attributes['url'] = $info['link'];
  		$this->attributes['photo'] = $info['pic'];
  
  		return true;
  	}
  
  }