Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
CustomVKontakteService.php
1 <?php
2 /**
3  * An example of extending the provider class.
4  *
5  * @author Maxim Zemskov <nodge@yandex.ru>
6  * @link http://code.google.com/p/yii-eauth/
7  * @license http://www.opensource.org/licenses/bsd-license.php
8  */
9 
10 require_once dirname(dirname(__FILE__)) . '/services/VKontakteOAuthService.php';
11 
13 
14  // protected $scope = 'friends';
15 
16  protected function fetchAttributes() {
17  $info = (array)$this->makeSignedRequest('https://api.vkontakte.ru/method/getProfiles', array(
18  'query' => array(
19  'uids' => $this->uid,
20  //'fields' => '', // uid, first_name and last_name is always available
21  'fields' => 'nickname, sex, bdate, city, country, timezone, photo, photo_medium, photo_big, photo_rec',
22  ),
23  ));
24 
25  $info = $info['response'][0];
26 
27  $this->attributes['id'] = $info->uid;
28  $this->attributes['name'] = $info->first_name.' '.$info->last_name;
29  $this->attributes['url'] = 'http://vkontakte.ru/id'.$info->uid;
30 
31  if (!empty($info->nickname))
32  $this->attributes['username'] = $info->nickname;
33  else
34  $this->attributes['username'] = 'id'.$info->uid;
35 
36  $this->attributes['gender'] = $info->sex == 1 ? 'F' : 'M';
37 
38  $this->attributes['city'] = $info->city;
39  $this->attributes['country'] = $info->country;
40 
41  $this->attributes['timezone'] = timezone_name_from_abbr('', $info->timezone*3600, date('I'));;
42 
43  $this->attributes['photo'] = $info->photo;
44  $this->attributes['photo_medium'] = $info->photo_medium;
45  $this->attributes['photo_big'] = $info->photo_big;
46  $this->attributes['photo_rec'] = $info->photo_rec;
47  }
48 }