Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Protected Member Functions | Protected Attributes | List of all members
OdnoklassnikiOAuthService Class Reference
Inheritance diagram for OdnoklassnikiOAuthService:
EOAuth2Service EAuthServiceBase IAuthService IAuthService CustomOdnoklassnikiService

Protected Member Functions

 fetchAttributes ()
 getTokenUrl ($code)
 getAccessToken ($code)
 getCodeUrl ($redirect_uri)
 fetchJsonError ($json)
- Protected Member Functions inherited from EOAuth2Service
 saveAccessToken ($token)
 restoreAccessToken ()
- Protected Member Functions inherited from EAuthServiceBase
 makeRequest ($url, $options=array(), $parseJson=true)
 initRequest ($url, $options=array())
 parseJson ($response)
 getStateKeyPrefix ()
 setState ($key, $value, $defaultValue=null)
 hasState ($key)
 getState ($key, $defaultValue=null)
 _fetchAttributes ()

Protected Attributes

 $name = 'odnoklassniki'
 $title = 'Odnoklassniki'
 $type = 'OAuth'
 $jsArguments = array('popup' => array('width' => 680, 'height' => 500))
 $client_id = ''
 $client_secret = ''
 $client_public = ''
 $scope = ''
 $providerOptions
- Protected Attributes inherited from EOAuth2Service
 $client_id
 $client_secret
 $scope = ''
 $providerOptions
 $access_token = ''
- Protected Attributes inherited from EAuthServiceBase
 $name
 $title
 $type
 $jsArguments = array()
 $attributes = array()
 $authenticated = false

Additional Inherited Members

- Public Member Functions inherited from EOAuth2Service
 authenticate ()
 makeSignedRequest ($url, $options=array(), $parseJson=true)

Detailed Description

Definition at line 18 of file OdnoklassnikiOAuthService.php.

Member Function Documentation

OdnoklassnikiOAuthService::fetchAttributes ( )
protected

Fetch attributes array.

Returns
boolean whether the attributes was successfully fetched.

Reimplemented from EAuthServiceBase.

Reimplemented in CustomOdnoklassnikiService.

Definition at line 34 of file OdnoklassnikiOAuthService.php.

References EAuthServiceBase\makeRequest().

{
$sig = strtolower(md5('application_key='.$this->client_public.'client_id='.$this->client_id.'format=JSONmethod=users.getCurrentUser'.md5($this->access_token.$this->client_secret)));
$info = $this->makeRequest('http://api.odnoklassniki.ru/fb.do', array(
'query' => array(
'method' => 'users.getCurrentUser',
'sig' => $sig,
'format' => 'JSON',
'application_key' => $this->client_public,
'client_id' => $this->client_id,
'access_token' => $this->access_token,
),
));
$this->attributes['id'] = $info->uid;
$this->attributes['name'] = $info->first_name.' '.$info->last_name;
}
OdnoklassnikiOAuthService::fetchJsonError (   $json)
protected

Returns the error info from json.

Parameters
stdClass$jsonthe json response.
Returns
array the error array with 2 keys: code and message. Should be null if no errors.

Reimplemented from EAuthServiceBase.

Definition at line 82 of file OdnoklassnikiOAuthService.php.

{
if (isset($json->error)) {
return array(
'code' => $json->error_code,
'message' => $json->error_description,
);
}
else
return null;
}
OdnoklassnikiOAuthService::getAccessToken (   $code)
protected

Returns the OAuth2 access token.

Parameters
string$codethe OAuth2 code. See getCodeUrl.
Returns
string the token.

Reimplemented from EOAuth2Service.

Definition at line 56 of file OdnoklassnikiOAuthService.php.

References EAuthServiceBase\getState(), getTokenUrl(), and EAuthServiceBase\makeRequest().

{
$params = array(
'client_id' => $this->client_id,
'client_secret' => $this->client_secret,
'grant_type' => 'authorization_code',
'code' => $code,
'redirect_uri' => $this->getState('redirect_uri'),
);
$url = $this->getTokenUrl($code).'?client_id='.$this->client_id.'&client_secret='.$this->client_secret.'&redirect_uri='.urlencode($this->getState('redirect_uri')).'&code='.$code.'&grant_type=authorization_code';
$result = $this->makeRequest($url, array('data' => $params));
return $result->access_token;
}
OdnoklassnikiOAuthService::getCodeUrl (   $redirect_uri)
protected

Returns the url to request to get OAuth2 code.

Parameters
string$redirect_uriurl to redirect after user confirmation.
Returns
string url to request.

Reimplemented from EOAuth2Service.

Definition at line 69 of file OdnoklassnikiOAuthService.php.

References EAuthServiceBase\setState().

{
$this->setState('redirect_uri', $redirect_uri);
$url = parent::getCodeUrl($redirect_uri);
if (isset($_GET['js']))
$url .= '&display=popup';
return $url;
}
OdnoklassnikiOAuthService::getTokenUrl (   $code)
protected

Returns the url to request to get OAuth2 access token.

Returns
string url to request.

Reimplemented from EOAuth2Service.

Definition at line 52 of file OdnoklassnikiOAuthService.php.

Referenced by getAccessToken().

{
return $this->providerOptions['access_token'];
}

Member Data Documentation

OdnoklassnikiOAuthService::$providerOptions
protected
Initial value:
array(
'authorize' => 'http://www.odnoklassniki.ru/oauth/authorize',
'access_token' => 'http://api.odnoklassniki.ru/oauth/token.do',
)

Definition at line 29 of file OdnoklassnikiOAuthService.php.


The documentation for this class was generated from the following file: