Class BaseFacebook
Provides access to the Facebook Platform. This class provides a majority of the functionality needed, but the class is abstract because it is designed to be sub-classed. The subclass must implement the four abstract methods listed at the bottom of the file.
Direct known subclasses
Facebook
public
|
|
public
|
|
public
string
|
|
public
|
|
public
string
|
|
public
|
|
public
boolean
|
|
public
boolean
|
|
public
|
#
setAccessToken( string $access_token )
Sets the access token for api calls. Use this if you get your access token by other means and just want the SDK to use it. |
public
string
|
#
getAccessToken( )
Determines the access token that should be used for API calls. The first time this is called, $this->accessToken is set equal to either a valid user access token, or it's set to the application access token if a valid user access token wasn't available. Subsequent calls return whatever the first call returned. |
protected
string
|
#
getUserAccessToken( )
Determines and returns the user access token, first using the signed request if present, and then falling back on the authorization code if present. The intent is to return a valid user access token, or false if one is determined to not be available. |
public
string
|
#
getSignedRequest( )
Retrieve the signed request, either from a request parameter or, if not present, from a cookie. |
public
string
|
|
protected
integer
|
#
getUserFromAvailableData( )
Determines the connected user by first examining any signed requests, then considering an authorization code, and then falling back to any persistent store storing the user. |
public
string
|
#
getLoginUrl( array $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. |
public
string
|
|
public
string
|
#
getLoginStatusUrl( array $params = array() )
Get a login status URL to fetch the status from Facebook. |
public
mixed
|
|
protected
string
|
#
getSignedRequestCookieName( )
Constructs and returns the name of the cookie that potentially houses the signed request for the app user. The cookie is not set by the BaseFacebook class, but it may be set by the JavaScript SDK. |
protected
string
|
#
getMetadataCookieName( )
Constructs and returns the name of the coookie that potentially contain metadata. The cookie is not set by the BaseFacebook class, but it may be set by the JavaScript SDK. |
protected
mixed
|
|
protected
integer
|
#
getUserFromAccessToken( )
Retrieves the UID with the understanding that $this->accessToken has already been set and is seemingly legitimate. It relies on Facebook's Graph API to retrieve user information and then extract the user ID. |
protected
string
|
#
getApplicationAccessToken( )
Returns the access token that should be used for logged out users when no authorization code is available. |
protected
|
|
protected
mixed
|
#
getAccessTokenFromCode( string $code, $redirect_uri = null )
Retrieves an access token for the given authorization code (previously generated from www.facebook.com on behalf of a specific user). The authorization code is sent to graph.facebook.com and a legitimate access token is generated provided the access token and the user for which it was generated all match, and the user is either logged in to Facebook or has granted an offline access permission. |
protected
mixed
|
|
protected
boolean
|
|
protected
mixed
|
|
protected
string
|
|
protected
string
|
#
makeRequest( string $url, array $params, CurlHandler $ch = null )
Makes an HTTP request. This method can be overridden by subclasses if developers want to do fancier things or use something other than curl to make the request. |
protected
array
|
|
protected
string
|
|
protected
string
|
|
protected
string
|
#
getCurrentUrl( )
Returns the Current URL, stripping it of known FB parameters that should not persist. |
protected
boolean
|
#
shouldRetainParam( string $param )
Returns true if and only if the key or key/value pair should be retained as part of the query string. This amounts to a brute-force search of the very small list of Facebook-specific params that should be stripped out. |
protected
|
#
throwAPIException( $result $result )
Analyzes the supplied result to see if it was thrown because the access token is no longer valid. If that is the case, then we destroy the session. |
protected static
|
|
protected static
string
|
#
base64UrlDecode( string $input )
Base64 encoding that doesn't need to be urlencode()ed. Exactly the same as base64_encode except it uses
_ instead of / |
public
|
|
protected
an
|
|
abstract protected
|
#
setPersistentData( string $key, array $value )
Stores the given ($key, $value) pair, so that future calls to getPersistentData($key) return $value. This call may be in another request. |
abstract protected
mixed
|
#
getPersistentData( string $key, boolean $default = false )
Get the data for $key, persisted by BaseFacebook::setPersistentData() |
abstract protected
|
|
abstract protected
|
string
|
VERSION
|
'3.1.1' |
#
Version. |
public static
array
|
$CURL_OPTS | array(
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_USERAGENT => 'facebook-php-3.1',
) |
#
Default options for curl. |
protected static
array
|
$DROP_QUERY_PARAMS | array(
'code',
'state',
'signed_request',
) |
#
List of query parameters that get automatically dropped when rebuilding the current URL. |
public static
array
|
$DOMAIN_MAP | array(
'api' => 'https://api.facebook.com/',
'api_video' => 'https://api-video.facebook.com/',
'api_read' => 'https://api-read.facebook.com/',
'graph' => 'https://graph.facebook.com/',
'graph_video' => 'https://graph-video.facebook.com/',
'www' => 'https://www.facebook.com/',
) |
#
Maps aliases to Facebook domains. |
protected
string
|
$appId |
|
#
The Application ID. |
protected
string
|
$appSecret |
|
#
The Application App Secret. |
protected
integer
|
$user |
|
#
The ID of the Facebook user, or 0 if the user is logged out. |
protected
|
$signedRequest |
|
#
The data from the signed_request token. |
protected
|
$state |
|
#
A CSRF state variable to assist in the defense against CSRF attacks. |
protected
string
|
$accessToken | null |
#
The OAuth access token received in exchange for a valid authorization code. null means the access token has yet to be determined. |
protected
boolean
|
$fileUploadSupport | false |
#
Indicates if the CURL based @ syntax for file uploads is enabled. |