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

Protected Member Functions

 fetchAttributes ()
 getCodeUrl ($redirect_uri)
 getTokenUrl ($code)
 getAccessToken ($code)
 saveAccessToken ($token)
 fetchJsonError ($json)
- Protected Member Functions inherited from EOAuth2Service
 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 = 'facebook'
 $title = 'Facebook'
 $type = 'OAuth'
 $jsArguments = array('popup' => array('width' => 585, 'height' => 290))
 $client_id = ''
 $client_secret = ''
 $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 FacebookOAuthService.php.

Member Function Documentation

FacebookOAuthService::fetchAttributes ( )
protected

Fetch attributes array.

Returns
boolean whether the attributes was successfully fetched.

Reimplemented from EAuthServiceBase.

Reimplemented in FacebookService.

Definition at line 33 of file FacebookOAuthService.php.

References EOAuth2Service\makeSignedRequest().

{
$info = (object) $this->makeSignedRequest('https://graph.facebook.com/me');
$this->attributes['id'] = $info->id;
$this->attributes['name'] = $info->name;
$this->attributes['url'] = $info->link;
}
FacebookOAuthService::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 FacebookOAuthService.php.

{
if (isset($json->error)) {
return array(
'code' => $json->error->code,
'message' => $json->error->message,
);
}
else
return null;
}
FacebookOAuthService::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 61 of file FacebookOAuthService.php.

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

{
$response = $this->makeRequest($this->getTokenUrl($code), array(), false);
parse_str($response, $result);
return $result;
}
FacebookOAuthService::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 41 of file FacebookOAuthService.php.

References EAuthServiceBase\setState().

{
if (strpos($redirect_uri, '?') !== false) {
$url = explode('?', $redirect_uri);
$url[1] = preg_replace('#[/]#', '%2F', $url[1]);
$redirect_uri = implode('?', $url);
}
$this->setState('redirect_uri', $redirect_uri);
$url = parent::getCodeUrl($redirect_uri);
if (isset($_GET['js']))
$url .= '&display=popup';
return $url;
}
FacebookOAuthService::getTokenUrl (   $code)
protected

Returns the url to request to get OAuth2 access token.

Returns
string url to request.

Reimplemented from EOAuth2Service.

Definition at line 57 of file FacebookOAuthService.php.

References EAuthServiceBase\getState().

Referenced by getAccessToken().

{
return parent::getTokenUrl($code).'&redirect_uri='.urlencode($this->getState('redirect_uri'));
}
FacebookOAuthService::saveAccessToken (   $token)
protected

Save access token to the session.

Parameters
array$tokenaccess token array.

Reimplemented from EOAuth2Service.

Definition at line 71 of file FacebookOAuthService.php.

References EAuthServiceBase\setState().

{
$this->setState('auth_token', $token['access_token']);
$this->setState('expires', isset($token['expires']) ? time() + (int)$token['expires'] - 60 : 0);
$this->access_token = $token['access_token'];
}

Member Data Documentation

FacebookOAuthService::$providerOptions
protected
Initial value:
array(
'authorize' => 'https://www.facebook.com/dialog/oauth',
'access_token' => 'https://graph.facebook.com/oauth/access_token',
)

Definition at line 28 of file FacebookOAuthService.php.


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