Created
January 13, 2015 10:24
-
-
Save dmeroff/293d84b4f578d8450959 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use yii\authclient\OAuth2; | |
class Odnoklassniki extends OAuth2 | |
{ | |
/** @inheritdoc */ | |
public $authUrl = 'http://www.odnoklassniki.ru/oauth/authorize'; | |
/** @inheritdoc */ | |
public $tokenUrl = 'http://api.odnoklassniki.ru/oauth/token.do'; | |
/** @inheritdoc */ | |
public $apiBaseUrl = 'http://api.odnoklassniki.ru/'; | |
/** @var string Публичный ключ */ | |
public $publicKey; | |
/** @inheritdoc */ | |
protected function defaultName() | |
{ | |
return 'odnoklassniki'; | |
} | |
/** @inheritdoc */ | |
protected function defaultTitle() | |
{ | |
return 'Одноклассники'; | |
} | |
/** @inheritdoc */ | |
protected function initUserAttributes() | |
{ | |
$token = $this->getAccessToken()->getParam('access_token'); | |
$sig = md5("application_key={$this->publicKey}format=jsonmethod=users.getCurrentUser" . md5("{$token}{$this->clientSecret}")); | |
$params = array( | |
'method' => 'users.getCurrentUser', | |
'access_token' => $token, | |
'application_key' => $this->publicKey, | |
'format' => 'json', | |
'sig' => $sig | |
); | |
return $this->api('fb.do', 'GET', $params); | |
} | |
/** @inheritdoc */ | |
protected function defaultNormalizeUserAttributeMap() | |
{ | |
return [ | |
'id' => 'uid' | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment