Public Member Functions | |
__construct ($config) | |
setAppId ($appId) | |
getAppId () | |
setApiSecret ($apiSecret) | |
getApiSecret () | |
setFileUploadSupport ($fileUploadSupport) | |
useFileUploadSupport () | |
setAccessToken ($access_token) | |
getAccessToken () | |
getSignedRequest () | |
getUser () | |
getLoginUrl ($params=array()) | |
getLogoutUrl ($params=array()) | |
getLoginStatusUrl ($params=array()) | |
api () | |
destroySession () | |
Public Attributes | |
const | VERSION = '3.1.1' |
Static Public Attributes | |
static | $CURL_OPTS |
static | $DOMAIN_MAP |
Protected Member Functions | |
getUserAccessToken () | |
getUserFromAvailableData () | |
getSignedRequestCookieName () | |
getCode () | |
getUserFromAccessToken () | |
getApplicationAccessToken () | |
establishCSRFTokenState () | |
getAccessTokenFromCode ($code, $redirect_uri=null) | |
_restserver ($params) | |
_graph ($path, $method= 'GET', $params=array()) | |
_oauthRequest ($url, $params) | |
makeRequest ($url, $params, $ch=null) | |
parseSignedRequest ($signed_request) | |
getApiUrl ($method) | |
getUrl ($name, $path='', $params=array()) | |
getCurrentUrl () | |
shouldRetainParam ($param) | |
throwAPIException ($result) | |
setPersistentData ($key, $value) | |
getPersistentData ($key, $default=false) | |
clearPersistentData ($key) | |
clearAllPersistentData () | |
Static Protected Member Functions | |
static | errorLog ($msg) |
static | base64UrlDecode ($input) |
Protected Attributes | |
$appId | |
$apiSecret | |
$user | |
$signedRequest | |
$state | |
$accessToken = null | |
$fileUploadSupport = false | |
Static Protected Attributes | |
static | $DROP_QUERY_PARAMS |
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.
Definition at line 118 of file base_facebook.php.
BaseFacebook.__construct | ( | $ | config | ) |
Initialize a Facebook Application.
The configuration:
array | $config The application configuration |
Reimplemented in Facebook.
Definition at line 212 of file base_facebook.php.
BaseFacebook._graph | ( | $ | path, | |
$ | method = 'GET' , |
|||
$ | params = array() | |||
) | [protected] |
Invoke the Graph API.
string | $path The path (required) | |
string | $method The http method (default 'GET') | |
array | $params The query/post data |
FacebookApiException |
Definition at line 730 of file base_facebook.php.
BaseFacebook._oauthRequest | ( | $ | url, | |
$ | params | |||
) | [protected] |
Make a OAuth Request.
string | $url The path (required) | |
array | $params The query/post data |
FacebookApiException |
Definition at line 759 of file base_facebook.php.
BaseFacebook._restserver | ( | $ | params | ) | [protected] |
Invoke the old restserver.php endpoint.
array | $params Method call object |
FacebookApiException |
Definition at line 697 of file base_facebook.php.
BaseFacebook.api | ( | ) |
Make an API call.
Definition at line 548 of file base_facebook.php.
static BaseFacebook.base64UrlDecode | ( | $ | input | ) | [static, protected] |
Base64 encoding that doesn't need to be urlencode()ed. Exactly the same as base64_encode except it uses
string | $input base64UrlEncoded string |
Definition at line 1085 of file base_facebook.php.
BaseFacebook.clearAllPersistentData | ( | ) | [abstract, protected] |
BaseFacebook.clearPersistentData | ( | $ | key | ) | [abstract, protected] |
Clear the data with $key from the persistent storage
string | $key |
Reimplemented in Facebook.
BaseFacebook.destroySession | ( | ) |
Destroy the current session
Definition at line 1092 of file base_facebook.php.
static BaseFacebook.errorLog | ( | $ | msg | ) | [static, protected] |
Prints to the error log if you aren't in command line mode.
string | $msg Log message |
Definition at line 1065 of file base_facebook.php.
BaseFacebook.establishCSRFTokenState | ( | ) | [protected] |
Lays down a CSRF state token for this process.
Definition at line 632 of file base_facebook.php.
BaseFacebook.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.
Definition at line 307 of file base_facebook.php.
BaseFacebook.getAccessTokenFromCode | ( | $ | code, | |
$ | redirect_uri = null | |||
) | [protected] |
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.
string | $code An authorization code. |
Definition at line 651 of file base_facebook.php.
BaseFacebook.getApiSecret | ( | ) |
BaseFacebook.getApiUrl | ( | $ | method | ) | [protected] |
Build the URL for api given parameters.
$method | String the method name. |
Definition at line 869 of file base_facebook.php.
BaseFacebook.getAppId | ( | ) |
Get the Application ID.
Definition at line 241 of file base_facebook.php.
BaseFacebook.getApplicationAccessToken | ( | ) | [protected] |
Returns the access token that should be used for logged out users when no authorization code is available.
Definition at line 623 of file base_facebook.php.
BaseFacebook.getCode | ( | ) | [protected] |
Get the authorization code from the query parameters, if it exists, and otherwise return false to signal no authorization code was discoverable.
Definition at line 578 of file base_facebook.php.
BaseFacebook.getCurrentUrl | ( | ) | [protected] |
Returns the Current URL, stripping it of known FB parameters that should not persist.
Definition at line 970 of file base_facebook.php.
BaseFacebook.getLoginStatusUrl | ( | $ | params = array() |
) |
Get a login status URL to fetch the status from Facebook.
The parameters:
array | $params Provide custom parameters |
Definition at line 529 of file base_facebook.php.
BaseFacebook.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:
array | $params Provide custom parameters |
Definition at line 478 of file base_facebook.php.
BaseFacebook.getLogoutUrl | ( | $ | params = array() |
) |
Get a Logout URL suitable for use with redirects.
The parameters:
array | $params Provide custom parameters |
Definition at line 507 of file base_facebook.php.
BaseFacebook.getPersistentData | ( | $ | key, | |
$ | default = false | |||
) | [abstract, protected] |
Get the data for $key, persisted by BaseFacebook.setPersistentData()
string | $key The key of the data to retrieve | |
boolean | $default The default value to return if $key is not found |
Reimplemented in Facebook.
BaseFacebook.getSignedRequest | ( | ) |
Retrieve the signed request, either from a request parameter or, if not present, from a cookie.
Definition at line 393 of file base_facebook.php.
BaseFacebook.getSignedRequestCookieName | ( | ) | [protected] |
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.
Definition at line 566 of file base_facebook.php.
BaseFacebook.getUrl | ( | $ | name, | |
$ | path = '' , |
|||
$ | params = array() | |||
) | [protected] |
Build the URL for given domain alias, path and parameters.
$name | string The name of the domain | |
$path | string Optional path (without a leading slash) | |
$params | array Optional query parameters |
Definition at line 949 of file base_facebook.php.
BaseFacebook.getUser | ( | ) |
Get the UID of the connected user, or 0 if the Facebook user is not connected.
Definition at line 412 of file base_facebook.php.
BaseFacebook.getUserAccessToken | ( | ) | [protected] |
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.
Definition at line 335 of file base_facebook.php.
BaseFacebook.getUserFromAccessToken | ( | ) | [protected] |
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.
Definition at line 607 of file base_facebook.php.
BaseFacebook.getUserFromAvailableData | ( | ) | [protected] |
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.
Definition at line 429 of file base_facebook.php.
BaseFacebook.makeRequest | ( | $ | url, | |
$ | params, | |||
$ | ch = null | |||
) | [protected] |
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.
string | $url The URL to make the request to | |
array | $params The parameters to use for the POST body | |
CurlHandler | $ch Initialized curl handle |
Definition at line 785 of file base_facebook.php.
BaseFacebook.parseSignedRequest | ( | $ | signed_request | ) | [protected] |
Parses a signed_request and validates the signature.
string | $signed_request A signed token |
Definition at line 840 of file base_facebook.php.
BaseFacebook.setAccessToken | ( | $ | 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.
string | $access_token an access token. |
Definition at line 293 of file base_facebook.php.
BaseFacebook.setApiSecret | ( | $ | apiSecret | ) |
Set the API Secret.
string | $apiSecret The API Secret |
Definition at line 251 of file base_facebook.php.
BaseFacebook.setAppId | ( | $ | appId | ) |
Set the Application ID.
string | $appId The Application ID |
Definition at line 231 of file base_facebook.php.
BaseFacebook.setFileUploadSupport | ( | $ | fileUploadSupport | ) |
Set the file upload support status.
boolean | $fileUploadSupport The file upload support status. |
Definition at line 271 of file base_facebook.php.
BaseFacebook.setPersistentData | ( | $ | key, | |
$ | value | |||
) | [abstract, protected] |
Each of the following four methods should be overridden in a concrete subclass, as they are in the provided Facebook class. The Facebook class uses PHP sessions to provide a primitive persistent store, but another subclass--one that you implement-- might use a database, memcache, or an in-memory cache.
string | $key | |
array | $value |
Reimplemented in Facebook.
BaseFacebook.shouldRetainParam | ( | $ | param | ) | [protected] |
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.
string | $param A key or key/value pair within a URL's query (e.g. 'foo=a', 'foo=', or 'foo'. |
Definition at line 1020 of file base_facebook.php.
BaseFacebook.throwAPIException | ( | $ | result | ) | [protected] |
Analyzes the supplied result to see if it was thrown because the access token is no longer valid. If that is the case, then the persistent store is cleared.
$result | array A record storing the error message returned by a failed API call. |
Definition at line 1038 of file base_facebook.php.
BaseFacebook.useFileUploadSupport | ( | ) |
Get the file upload support status.
Definition at line 281 of file base_facebook.php.
BaseFacebook.$accessToken = null [protected] |
Definition at line 193 of file base_facebook.php.
BaseFacebook.$apiSecret [protected] |
Definition at line 168 of file base_facebook.php.
BaseFacebook.$appId [protected] |
Definition at line 161 of file base_facebook.php.
BaseFacebook.$CURL_OPTS [static] |
array( CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 60, CURLOPT_USERAGENT => 'facebook-php-3.1', )
Default options for curl.
Definition at line 128 of file base_facebook.php.
BaseFacebook.$DOMAIN_MAP [static] |
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/', 'www' => 'https://www.facebook.com/', )
Maps aliases to Facebook domains.
Definition at line 148 of file base_facebook.php.
BaseFacebook.$DROP_QUERY_PARAMS [static, protected] |
array( 'code', 'state', 'signed_request', )
List of query parameters that get automatically dropped when rebuilding the current URL.
Definition at line 139 of file base_facebook.php.
BaseFacebook.$fileUploadSupport = false [protected] |
Definition at line 200 of file base_facebook.php.
BaseFacebook.$signedRequest [protected] |
The data from the signed_request token.
Definition at line 180 of file base_facebook.php.
BaseFacebook.$state [protected] |
A CSRF state variable to assist in the defense against CSRF attacks.
Definition at line 185 of file base_facebook.php.
BaseFacebook.$user [protected] |
Definition at line 175 of file base_facebook.php.
const BaseFacebook.VERSION = '3.1.1' |
Version.
Definition at line 123 of file base_facebook.php.