Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes

Facebook Class Reference

Inheritance diagram for Facebook:
Collaboration diagram for Facebook:

List of all members.

Public Member Functions

 __construct ($config)
 setAppId ($appId)
 getAppId ()
 setApiSecret ($apiSecret)
 getApiSecret ()
 setCookieSupport ($cookieSupport)
 useCookieSupport ()
 setBaseDomain ($domain)
 getBaseDomain ()
 setSession ($session=null, $write_cookie=true)
 getSession ()
 getUser ()
 getLoginUrl ($params=array())
 getLogoutUrl ($params=array())
 getLoginStatusUrl ($params=array())
 api ()

Public Attributes

const VERSION = '2.0.3'

Static Public Attributes

static $CURL_OPTS
static $DOMAIN_MAP

Protected Member Functions

 _restserver ($params)
 _graph ($path, $method='GET', $params=array())
 _oauthRequest ($url, $params)
 makeRequest ($url, $params, $ch=null)
 getSessionCookieName ()
 setCookieFromSession ($session=null)
 validateSessionObject ($session)
 getApiUrl ($method)
 getUrl ($name, $path='', $params=array())
 getCurrentUrl ()

Static Protected Member Functions

static generateSignature ($params, $secret)

Protected Attributes

 $appId
 $apiSecret
 $session
 $sessionLoaded = false
 $cookieSupport = false
 $baseDomain = ''

Static Protected Attributes

static $DROP_QUERY_PARAMS

Detailed Description

Provides access to the Facebook Platform.

Author:
Naitik Shah <[email protected]>

Definition at line 77 of file facebook.php.


Constructor & Destructor Documentation

Facebook.__construct ( config  ) 

Initialize a Facebook Application.

The configuration:

  • appId: the application API key
  • secret: the application secret
  • cookie: (optional) boolean true to enable cookie support
  • domain: (optional) domain for the cookie
Parameters:
Array $config the application configuration

Definition at line 153 of file facebook.php.


Member Function Documentation

Facebook._graph ( path,
method = 'GET',
params = array() 
) [protected]

Invoke the Graph API.

Parameters:
String $path the path (required)
String $method the http method (default 'GET')
Array $params the query/post data
Returns:
the decoded response object
Exceptions:
FacebookApiException 

Definition at line 439 of file facebook.php.

Facebook._oauthRequest ( url,
params 
) [protected]

Make a OAuth Request

Parameters:
String $path the path (required)
Array $params the query/post data
Returns:
the decoded response object
Exceptions:
FacebookApiException 

Definition at line 470 of file facebook.php.

Facebook._restserver ( params  )  [protected]

Invoke the old restserver.php endpoint.

Parameters:
Array $params method call object
Returns:
the decoded response object
Exceptions:
FacebookApiException 

Definition at line 413 of file facebook.php.

Facebook.api (  ) 

Make an API call.

Parameters:
Array $params the API call parameters
Returns:
the decoded response

Definition at line 397 of file facebook.php.

static Facebook.generateSignature ( params,
secret 
) [static, protected]

Generate a signature for the given params and secret.

Parameters:
Array $params the parameters to sign
String $secret the secret to sign with
Returns:
String the generated signature

Definition at line 747 of file facebook.php.

Facebook.getApiSecret (  ) 

Get the API Secret.

Returns:
String the API Secret

Definition at line 198 of file facebook.php.

Facebook.getApiUrl ( method  )  [protected]

Build the URL for api given parameters.

Parameters:
$method String the method name.
Returns:
String the URL for the given parameters

Definition at line 612 of file facebook.php.

Facebook.getAppId (  ) 

Get the API Key.

Returns:
String the API key

Definition at line 179 of file facebook.php.

Facebook.getBaseDomain (  ) 

Get the base domain for the Cookie.

Returns:
String the base domain

Definition at line 236 of file facebook.php.

Facebook.getCurrentUrl (  )  [protected]

Returns the Current URL, stripping it of known FB parameters that should not persist.

Returns:
String the current URL

Definition at line 709 of file facebook.php.

Facebook.getLoginStatusUrl ( params = array()  ) 

Get a login status URL to fetch the status from facebook.

The parameters:

  • ok_session: the URL to go to if a session is found
  • no_session: the URL to go to if the user is not connected
  • no_user: the URL to go to if the user is not signed into facebook
Parameters:
Array $params provide custom parameters
Returns:
String the URL for the logout flow

Definition at line 377 of file facebook.php.

Facebook.getLoginUrl ( params = array()  ) 

Get a Login URL for use with redirects. By default, full page redirect is assumed. If you are using the generated URL with a window.open() call in JavaScript, you can pass in display=popup as part of the $params.

The parameters:

  • next: the url to go to after a successful login
  • cancel_url: the url to go to after the user cancels
  • req_perms: comma separated list of requested extended perms
  • display: can be "page" (default, full page) or "popup"
Parameters:
Array $params provide custom parameters
Returns:
String the URL for the login flow

Definition at line 326 of file facebook.php.

Facebook.getLogoutUrl ( params = array()  ) 

Get a Logout URL suitable for use with redirects.

The parameters:

  • next: the url to go to after a successful logout
Parameters:
Array $params provide custom parameters
Returns:
String the URL for the logout flow

Definition at line 353 of file facebook.php.

Facebook.getSession (  ) 

Get the session object. This will automatically look for a signed session sent via the Cookie or Query Parameters if needed.

Returns:
Array the session

Definition at line 263 of file facebook.php.

Facebook.getSessionCookieName (  )  [protected]

The name of the Cookie that contains the session.

Returns:
String the cookie name

Definition at line 520 of file facebook.php.

Facebook.getUrl ( name,
path = '',
params = array() 
) [protected]

Build the URL for given domain alias, path and parameters.

Parameters:
$name String the name of the domain
$path String optional path (without a leading slash)
$params Array optional query parameters
Returns:
String the URL for the given parameters

Definition at line 689 of file facebook.php.

Facebook.getUser (  ) 

Get the UID from the session.

Returns:
String the UID if available

Definition at line 307 of file facebook.php.

Facebook.makeRequest ( url,
params,
ch = null 
) [protected]

Makes an HTTP request. This method can be overriden by subclasses if developers want to do fancier things or use something other than curl to make the request.

Parameters:
String $url the URL to make the request to
Array $params the parameters to use for the POST body
CurlHandler $ch optional initialized curl handle
Returns:
String the response text

Definition at line 501 of file facebook.php.

Facebook.setApiSecret ( apiSecret  ) 

Set the API Secret.

Parameters:
String $appId the API Secret

Definition at line 188 of file facebook.php.

Facebook.setAppId ( appId  ) 

Set the Application ID.

Parameters:
String $appId the API key

Definition at line 169 of file facebook.php.

Facebook.setBaseDomain ( domain  ) 

Set the base domain for the Cookie.

Parameters:
String $domain the base domain

Definition at line 226 of file facebook.php.

Facebook.setCookieFromSession ( session = null  )  [protected]

Set a JS Cookie based on the _passed in_ session. It does not use the currently stored session -- you need to explicitly pass it in.

Parameters:
Array $session the session to use for setting the cookie

Definition at line 530 of file facebook.php.

Facebook.setCookieSupport ( cookieSupport  ) 

Set the Cookie Support status.

Parameters:
Boolean $cookieSupport the Cookie Support status

Definition at line 207 of file facebook.php.

Facebook.setSession ( session = null,
write_cookie = true 
)

Set the Session.

Parameters:
Array $session the session
Boolean $write_cookie indicate if a cookie should be written. this value is ignored if cookie support has been disabled.

Definition at line 247 of file facebook.php.

Facebook.useCookieSupport (  ) 

Get the Cookie Support status.

Returns:
Boolean the Cookie Support status

Definition at line 217 of file facebook.php.

Facebook.validateSessionObject ( session  )  [protected]

Validates a session_version=3 style session object.

Parameters:
Array $session the session object
Returns:
Array the session object if it validates, null otherwise

Definition at line 575 of file facebook.php.


Member Data Documentation

Facebook.$apiSecret [protected]

The Application API Secret.

Definition at line 120 of file facebook.php.

Facebook.$appId [protected]

The Application ID.

Definition at line 115 of file facebook.php.

Facebook.$baseDomain = '' [protected]

Base domain for the Cookie.

Definition at line 140 of file facebook.php.

Facebook.$cookieSupport = false [protected]

Indicates if Cookie support should be enabled.

Definition at line 135 of file facebook.php.

Facebook.$CURL_OPTS [static]
Initial value:
 array(
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 60,
    CURLOPT_USERAGENT      => 'facebook-php-2.0',
  )

Default options for curl.

Definition at line 87 of file facebook.php.

Facebook.$DOMAIN_MAP [static]
Initial value:
 array(
    'api'      => 'https://api.facebook.com/',
    'api_read' => 'https://api-read.facebook.com/',
    'graph'    => 'https://graph.facebook.com/',
    'www'      => 'https://www.facebook.com/',
  )

Maps aliases to Facebook domains.

Definition at line 105 of file facebook.php.

Facebook.$DROP_QUERY_PARAMS [static, protected]
Initial value:
 array(
    'session',
  )

List of query parameters that get automatically dropped when rebuilding the current URL.

Definition at line 98 of file facebook.php.

Facebook.$session [protected]

The active user session, if one is available.

Definition at line 125 of file facebook.php.

Facebook.$sessionLoaded = false [protected]

Indicates that we already loaded the session as best as we could.

Definition at line 130 of file facebook.php.

const Facebook.VERSION = '2.0.3'

Version.

Definition at line 82 of file facebook.php.


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