Class Facebook

Description

Provides access to the Facebook Platform.

Located in /vendors/facebook/src/facebook.php (line 98)


	
			
Direct descendents
Class Description
FBPublic Provides access to the Facebook Platform.
Class Constant Summary
 VERSION = '2.1.2'
Variable Summary
static mixed $CURL_OPTS
static mixed $DOMAIN_MAP
static mixed $DROP_QUERY_PARAMS
mixed $apiSecret
mixed $appId
mixed $baseDomain
mixed $session
Method Summary
static void base64UrlDecode (String $input)
static void errorLog (String $msg)
static String generateSignature (Array $params, String $secret)
Facebook __construct (Array $config)
the api (Array $params)
Array createSessionFromSignedRequest (Array $data)
String getAccessToken ()
String getApiSecret ()
String getApiUrl ($method $method)
String getAppId ()
String getBaseDomain ()
String getCurrentUrl ()
String getLoginStatusUrl ([Array $params = array()])
String getLoginUrl ([Array $params = array()])
String getLogoutUrl ([Array $params = array()])
Array getSession ()
String getSignedRequest ()
String getUrl ($name $name, [$path $path = ''], [$params $params = array()])
String getUser ()
String makeRequest (String $url, Array $params, [CurlHandler $ch = null])
Array parseSignedRequest (String $signed_request, Boolean 1)
void setApiSecret ( $apiSecret, String $appId)
void setAppId (String $appId)
void setBaseDomain (String $domain)
void setCookieFromSession ([Array $session = null])
void setCookieSupport (Boolean $cookieSupport)
void setFileUploadSupport ( $fileUploadSupport, String $domain)
void setSession ([Array $session = null], [Boolean $write_cookie = true])
Boolean useCookieSupport ()
Array validateSessionObject (Array $session)
the _graph (String $path, [String $method = 'GET'], [Array $params = array()])
the _oauthRequest ( $url, Array $params, String $path)
the _restserver (Array $params)
Variables
static mixed $CURL_OPTS = array(
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_USERAGENT => 'facebook-php-2.0',
)
(line 108)

Default options for curl.

  • access: public
static mixed $DOMAIN_MAP = array(
'api' => 'https://api.facebook.com/',
'api_read' => 'https://api-read.facebook.com/',
'graph' => 'https://graph.facebook.com/',
'www' => 'https://www.facebook.com/',
)
(line 127)

Maps aliases to Facebook domains.

  • access: public
static mixed $DROP_QUERY_PARAMS = array(
'session',
'signed_request',
)
(line 119)

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

  • access: protected
mixed $apiSecret (line 142)

The Application API Secret.

  • access: protected
mixed $appId (line 137)

The Application ID.

  • access: protected
mixed $baseDomain = '' (line 167)

Base domain for the Cookie.

  • access: protected
mixed $cookieSupport = false (line 162)

Indicates if Cookie support should be enabled.

  • access: protected
mixed $fileUploadSupport = false (line 172)

Indicates if the CURL based @ syntax for file uploads is enabled.

  • access: protected
mixed $session (line 147)

The active user session, if one is available.

  • access: protected
mixed $sessionLoaded = false (line 157)

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

  • access: protected
mixed $signedRequest (line 152)

The data from the signed_request token.

  • access: protected
Methods
static method base64UrlDecode (line 960)

Base64 encoding that doesn't need to be urlencode()ed.

Exactly the same as base64_encode except it uses

  • instead of +
_ instead of /

  • access: protected
static void base64UrlDecode (String $input)
  • String $input: base64UrlEncodeded string
static method errorLog (line 941)

Prints to the error log if you aren't in command line mode.

  • access: protected
static void errorLog (String $msg)
  • String $msg: log message
static method generateSignature (line 922)

Generate a signature for the given params and secret.

  • return: the generated signature
  • access: protected
static String generateSignature (Array $params, String $secret)
  • Array $params: the parameters to sign
  • String $secret: the secret to sign with
Constructor __construct (line 186)

Initialize a Facebook Application.

The configuration:

  • appId: the application ID
  • secret: the application secret
  • cookie: (optional) boolean true to enable cookie support
  • domain: (optional) domain for the cookie
  • fileUpload: (optional) boolean indicating if file uploads are enabled

  • access: public
Facebook __construct (Array $config)
  • Array $config: the application configuration
api (line 487)

Make an API call.

  • return: decoded response
  • access: public
the api (Array $params)
  • Array $params: the API call parameters
createSessionFromSignedRequest (line 729)

Returns something that looks like our JS session object from the signed token's data

TODO: Nuke this once the login flow uses OAuth2

  • return: Something that will work as a session
  • access: protected
Array createSessionFromSignedRequest (Array $data)
  • Array $data: the output of getSignedRequest
getAccessToken (line 394)

Gets a OAuth access token.

  • return: the access token
  • access: public
String getAccessToken ()
getApiSecret (line 234)

Get the API Secret.

  • return: the API Secret
  • access: public
String getApiSecret ()
getApiUrl (line 787)

Build the URL for api given parameters.

  • return: the URL for the given parameters
  • access: protected
String getApiUrl ($method $method)
  • $method $method: String the method name.
getAppId (line 215)

Get the Application ID.

  • return: the Application ID
  • access: public
String getAppId ()
getBaseDomain (line 272)

Get the base domain for the Cookie.

  • return: the base domain
  • access: public
String getBaseDomain ()
getCurrentUrl (line 884)

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

  • return: the current URL
  • access: protected
String getCurrentUrl ()
getLoginStatusUrl (line 467)

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

  • return: the URL for the logout flow
  • access: public
String getLoginStatusUrl ([Array $params = array()])
  • Array $params: provide custom parameters
getLoginUrl (line 418)

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"

  • return: the URL for the login flow
  • access: public
String getLoginUrl ([Array $params = array()])
  • Array $params: provide custom parameters
getLogoutUrl (line 445)

Get a Logout URL suitable for use with redirects.

The parameters:

  • next: the url to go to after a successful logout

  • return: the URL for the logout flow
  • access: public
String getLogoutUrl ([Array $params = array()])
  • Array $params: provide custom parameters
getSession (line 333)

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

  • return: the session
  • access: public
Array getSession ()
getSessionCookieName (line 641)

The name of the Cookie that contains the session.

  • return: the cookie name
  • access: protected
String getSessionCookieName ()
getSignedRequest (line 300)

Get the data from a signed_request token

  • return: the base domain
  • access: public
String getSignedRequest ()
getUrl (line 864)

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

  • return: the URL for the given parameters
  • access: protected
String getUrl ($name $name, [$path $path = ''], [$params $params = array()])
  • $name $name: String the name of the domain
  • $path $path: String optional path (without a leading slash)
  • $params $params: Array optional query parameters
getUser (line 384)

Get the UID from the session.

  • return: the UID if available
  • access: public
String getUser ()
makeRequest (line 588)

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.

  • return: the response text
  • access: protected
String makeRequest (String $url, Array $params, [CurlHandler $ch = null])
  • 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
parseSignedRequest (line 758)

Parses a signed_request and validates the signature.

Then saves it in $this->signed_data

  • return: the payload inside it or null if the sig is wrong
  • access: protected
Array parseSignedRequest (String $signed_request, Boolean 1)
  • Boolean 1: Should we remove the parts of the payload that are used by the algorithm?
  • String $signed_request: A signed token
setApiSecret (line 224)

Set the API Secret.

  • access: public
void setApiSecret ( $apiSecret, String $appId)
  • String $appId: the API Secret
  • $apiSecret
setAppId (line 205)

Set the Application ID.

  • access: public
void setAppId (String $appId)
  • String $appId: the Application ID
setBaseDomain (line 262)

Set the base domain for the Cookie.

  • access: public
void setBaseDomain (String $domain)
  • String $domain: the base domain
setCookieFromSession (line 651)

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.

  • access: protected
void setCookieFromSession ([Array $session = null])
  • Array $session: the session to use for setting the cookie
setCookieSupport (line 243)

Set the Cookie Support status.

  • access: public
void setCookieSupport (Boolean $cookieSupport)
  • Boolean $cookieSupport: the Cookie Support status
setFileUploadSupport (line 281)

Set the file upload support status.

  • access: public
void setFileUploadSupport ( $fileUploadSupport, String $domain)
  • String $domain: the base domain
  • $fileUploadSupport
setSession (line 317)

Set the Session.

  • access: public
void setSession ([Array $session = null], [Boolean $write_cookie = true])
  • Array $session: the session
  • Boolean $write_cookie: indicate if a cookie should be written. this value is ignored if cookie support has been disabled.
useCookieSupport (line 253)

Get the Cookie Support status.

  • return: the Cookie Support status
  • access: public
Boolean useCookieSupport ()
useFileUploadSupport (line 291)

Get the file upload support status.

  • return: the base domain
  • access: public
String useFileUploadSupport ()
validateSessionObject (line 696)

Validates a session_version=3 style session object.

  • return: the session object if it validates, null otherwise
  • access: protected
Array validateSessionObject (Array $session)
  • Array $session: the session object
_graph (line 529)

Invoke the Graph API.

  • return: decoded response object
  • throws: FacebookApiException
  • access: protected
the _graph (String $path, [String $method = 'GET'], [Array $params = array()])
  • String $path: the path (required)
  • String $method: the http method (default 'GET')
  • Array $params: the query/post data
_oauthRequest (line 564)

Make a OAuth Request

  • return: decoded response object
  • throws: FacebookApiException
  • access: protected
the _oauthRequest ( $url, Array $params, String $path)
  • String $path: the path (required)
  • Array $params: the query/post data
  • $url
_restserver (line 503)

Invoke the old restserver.php endpoint.

  • return: decoded response object
  • throws: FacebookApiException
  • access: protected
the _restserver (Array $params)
  • Array $params: method call object
Class Constants
VERSION = '2.1.2' (line 103)

Version.

Documentation generated on Mon, 29 Nov 2010 23:20:59 -0500 by phpDocumentor 1.4.3