Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dmeroff
Created January 13, 2015 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dmeroff/293d84b4f578d8450959 to your computer and use it in GitHub Desktop.
Save dmeroff/293d84b4f578d8450959 to your computer and use it in GitHub Desktop.
<?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