Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
CustomOdnoklassnikiService.php
1 <?php
2 /**
3  * CustomOdnoklassnikiService class file.
4  *
5  * @author Sergey Vardanyan <rakot.ss@gmail.com>
6  * @license http://www.opensource.org/licenses/bsd-license.php
7  */
8 
9 require_once dirname(dirname(__FILE__)) . '/services/OdnoklassnikiOAuthService.php';
10 
12 
13  protected $scope = 'VALUABLE ACCESS';
14 
15  protected function fetchAttributes() {
17  if ($this->scope == 'VALUABLE ACCESS')
18  $this->getRealIdAndUrl();
19  }
20 
21  /**
22  * Avable only if VALUABLE ACCESS is on
23  * you should ask for enable this scope for odnoklassniki administration
24  */
25  protected function getRealIdAndUrl() {
26  $sig = strtolower(md5('application_key='.$this->client_public.'client_id='.$this->client_id.'fields=url_profileformat=JSONmethod=users.getInfouids='.$this->attributes['id'].md5($this->access_token.$this->client_secret)));
27 
28  $info = $this->makeRequest('http://api.odnoklassniki.ru/fb.do', array(
29  'query' => array(
30  'method' => 'users.getInfo',
31  'sig' => $sig,
32  'uids' => $this->attributes['id'],
33  'fields' => 'url_profile',
34  'format' => 'JSON',
35  'application_key' => $this->client_public,
36  'client_id' => $this->client_id,
37  'access_token' => $this->access_token,
38  ),
39  ));
40 
41  preg_match('/\d+\/{0,1}$/',$info[0]->url_profile, $matches);
42  $this->attributes['id'] = (int)$matches[0];
43  $this->attributes['url'] = $info[0]->url_profile;
44  }
45 
46 }