ILIAS
release_5-3 Revision v5.3.23-19-g915713cf615
|
Provides access to the Facebook Platform. More...
Public Member Functions | |
__construct ($config) | |
Initialize a Facebook Application. More... | |
setAppId ($appId) | |
Set the Application ID. More... | |
getAppId () | |
Get the Application ID. More... | |
setApiSecret ($apiSecret) | |
Set the App Secret. More... | |
setAppSecret ($appSecret) | |
Set the App Secret. More... | |
getApiSecret () | |
Get the App Secret. More... | |
getAppSecret () | |
Get the App Secret. More... | |
setFileUploadSupport ($fileUploadSupport) | |
Set the file upload support status. More... | |
getFileUploadSupport () | |
Get the file upload support status. More... | |
useFileUploadSupport () | |
DEPRECATED! Please use getFileUploadSupport instead. More... | |
setAccessToken ($access_token) | |
Sets the access token for api calls. More... | |
setExtendedAccessToken () | |
Extend an access token, while removing the short-lived token that might have been generated via client-side flow. More... | |
getAccessToken () | |
Determines the access token that should be used for API calls. More... | |
getSignedRequest () | |
Retrieve the signed request, either from a request parameter or, if not present, from a cookie. More... | |
getUser () | |
Get the UID of the connected user, or 0 if the Facebook user is not connected. More... | |
getLoginUrl ($params=array()) | |
Get a Login URL for use with redirects. More... | |
getLogoutUrl ($params=array()) | |
Get a Logout URL suitable for use with redirects. More... | |
getLoginStatusUrl ($params=array()) | |
Get a login status URL to fetch the status from Facebook. More... | |
api () | |
Make an API call. More... | |
destroySession () | |
Destroy the current session. More... | |
Data Fields | |
const | VERSION = '3.2.2' |
Version. More... | |
const | SIGNED_REQUEST_ALGORITHM = 'HMAC-SHA256' |
Signed Request Algorithm. More... | |
Static Public Attributes | |
static | $CURL_OPTS |
Default options for curl. More... | |
static | $DOMAIN_MAP |
Maps aliases to Facebook domains. More... | |
Protected Member Functions | |
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. More... | |
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. More... | |
getSignedRequestCookieName () | |
Constructs and returns the name of the cookie that potentially houses the signed request for the app user. More... | |
getMetadataCookieName () | |
Constructs and returns the name of the coookie that potentially contain metadata. More... | |
getCode () | |
Get the authorization code from the query parameters, if it exists, and otherwise return false to signal no authorization code was discoverable. More... | |
getUserFromAccessToken () | |
Retrieves the UID with the understanding that $this->accessToken has already been set and is seemingly legitimate. More... | |
getApplicationAccessToken () | |
Returns the access token that should be used for logged out users when no authorization code is available. More... | |
establishCSRFTokenState () | |
Lays down a CSRF state token for this process. More... | |
getAccessTokenFromCode ($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). More... | |
_restserver ($params) | |
Invoke the old restserver.php endpoint. More... | |
isVideoPost ($path, $method='GET') | |
Return true if this is video post. More... | |
_graph ($path, $method='GET', $params=array()) | |
Invoke the Graph API. More... | |
_oauthRequest ($url, $params) | |
Make a OAuth Request. More... | |
makeRequest ($url, $params, $ch=null) | |
Makes an HTTP request. More... | |
parseSignedRequest ($signed_request) | |
Parses a signed_request and validates the signature. More... | |
makeSignedRequest ($data) | |
Makes a signed_request blob using the given data. More... | |
getApiUrl ($method) | |
Build the URL for api given parameters. More... | |
getUrl ($name, $path='', $params=array()) | |
Build the URL for given domain alias, path and parameters. More... | |
getHttpHost () | |
getHttpProtocol () | |
getBaseDomain () | |
Get the base domain used for the cookie. More... | |
getCurrentUrl () | |
Returns the Current URL, stripping it of known FB parameters that should not persist. More... | |
shouldRetainParam ($param) | |
Returns true if and only if the key or key/value pair should be retained as part of the query string. More... | |
throwAPIException ($result) | |
Analyzes the supplied result to see if it was thrown because the access token is no longer valid. More... | |
getMetadataCookie () | |
Parses the metadata cookie that our Javascript API set. More... | |
setPersistentData ($key, $value) | |
Each of the following four methods should be overridden in a concrete subclass, as they are in the provided Facebook class. More... | |
getPersistentData ($key, $default=false) | |
Get the data for $key, persisted by BaseFacebook::setPersistentData() More... | |
clearPersistentData ($key) | |
Clear the data with $key from the persistent storage. More... | |
clearAllPersistentData () | |
Clear all data from the persistent storage. More... | |
Static Protected Member Functions | |
static | errorLog ($msg) |
Prints to the error log if you aren't in command line mode. More... | |
static | base64UrlDecode ($input) |
Base64 encoding that doesn't need to be urlencode()ed. More... | |
static | base64UrlEncode ($input) |
Base64 encoding that doesn't need to be urlencode()ed. More... | |
static | isAllowedDomain ($big, $small) |
static | endsWith ($big, $small) |
Protected Attributes | |
$appId | |
$appSecret | |
$user | |
$signedRequest | |
The data from the signed_request token. More... | |
$state | |
A CSRF state variable to assist in the defense against CSRF attacks. More... | |
$accessToken = null | |
$fileUploadSupport = false | |
$trustForwarded = false | |
Static Protected Attributes | |
static | $DROP_QUERY_PARAMS |
List of query parameters that get automatically dropped when rebuilding the current URL. More... | |
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 |
Definition at line 225 of file base_facebook.php.
References $config, and $state.
|
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 859 of file base_facebook.php.
References $params, $path, and FacebookApiException\$result.
|
protected |
Make a OAuth Request.
string | $url | The path (required) |
array | $params | The query/post data |
FacebookApiException |
Definition at line 896 of file base_facebook.php.
References $key, $params, and $url.
|
protected |
Invoke the old restserver.php endpoint.
array | $params | Method call object |
FacebookApiException |
Definition at line 808 of file base_facebook.php.
References $params, and FacebookApiException\$result.
BaseFacebook::api | ( | ) |
Make an API call.
Definition at line 649 of file base_facebook.php.
References array.
|
staticprotected |
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 1297 of file base_facebook.php.
|
staticprotected |
Base64 encoding that doesn't need to be urlencode()ed.
Exactly the same as base64_encode except it uses
string | $input | string |
Definition at line 1310 of file base_facebook.php.
|
abstractprotected |
Clear all data from the persistent storage.
|
abstractprotected |
Clear the data with $key from the persistent storage.
string | $key |
BaseFacebook::destroySession | ( | ) |
Destroy the current session.
Definition at line 1319 of file base_facebook.php.
References $_COOKIE, and user().
|
staticprotected |
Definition at line 1383 of file base_facebook.php.
References $key.
|
staticprotected |
Prints to the error log if you aren't in command line mode.
string | $msg | Log message |
Definition at line 1278 of file base_facebook.php.
References Monolog\Handler\error_log().
|
protected |
Lays down a CSRF state token for this process.
Definition at line 744 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 398 of file base_facebook.php.
References $accessToken.
|
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 763 of file base_facebook.php.
References $code, $params, and array.
BaseFacebook::getApiSecret | ( | ) |
|
protected |
Build the URL for api given parameters.
$method | String the method name. |
Definition at line 1046 of file base_facebook.php.
BaseFacebook::getAppId | ( | ) |
Get the Application ID.
Definition at line 256 of file base_facebook.php.
Referenced by sspmod_authfacebook_Facebook\constructSessionVariableName(), and sspmod_authfacebook_Facebook\getSharedSessionCookieName().
|
protected |
Returns the access token that should be used for logged out users when no authorization code is available.
Definition at line 735 of file base_facebook.php.
BaseFacebook::getAppSecret | ( | ) |
|
protected |
Get the base domain used for the cookie.
Definition at line 1171 of file base_facebook.php.
References $metadata.
Referenced by sspmod_authfacebook_Facebook\deleteSharedSessionCookie(), and sspmod_authfacebook_Facebook\initSharedSession().
|
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 690 of file base_facebook.php.
|
protected |
Returns the Current URL, stripping it of known FB parameters that should not persist.
Definition at line 1188 of file base_facebook.php.
References $params, GuzzleHttp\Psr7\$protocol, $query, and array.
BaseFacebook::getFileUploadSupport | ( | ) |
Get the file upload support status.
Definition at line 318 of file base_facebook.php.
|
protected |
Definition at line 1141 of file base_facebook.php.
References $_SERVER.
Referenced by sspmod_authfacebook_Facebook\initSharedSession().
|
protected |
Definition at line 1148 of file base_facebook.php.
References $_SERVER.
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 630 of file base_facebook.php.
References $params, and array.
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 579 of file base_facebook.php.
References $params, and array.
BaseFacebook::getLogoutUrl | ( | $params = array() | ) |
Get a Logout URL suitable for use with redirects.
The parameters:
array | $params | Provide custom parameters |
Definition at line 608 of file base_facebook.php.
References $params, and array.
|
protected |
Parses the metadata cookie that our Javascript API set.
Definition at line 1350 of file base_facebook.php.
References $_COOKIE, $metadata, and array.
|
protected |
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.
Definition at line 678 of file base_facebook.php.
|
abstractprotected |
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 |
BaseFacebook::getSignedRequest | ( | ) |
Retrieve the signed request, either from a request parameter or, if not present, from a cookie.
Definition at line 489 of file base_facebook.php.
References $_COOKIE.
|
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 667 of file base_facebook.php.
|
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 1126 of file base_facebook.php.
References $name, $params, $path, and $url.
BaseFacebook::getUser | ( | ) |
Get the UID of the connected user, or 0 if the Facebook user is not connected.
Definition at line 508 of file base_facebook.php.
References user().
|
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 426 of file base_facebook.php.
References $code.
|
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 719 of file base_facebook.php.
|
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 525 of file base_facebook.php.
|
staticprotected |
Definition at line 1376 of file base_facebook.php.
|
protected |
Return true if this is video post.
string | $path | The path |
string | $method | The http method (default 'GET') |
Definition at line 842 of file base_facebook.php.
References $path.
|
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 922 of file base_facebook.php.
References $params, FacebookApiException\$result, $url, and array.
|
protected |
Makes a signed_request blob using the given data.
array | The data array. |
Definition at line 1026 of file base_facebook.php.
Referenced by sspmod_authfacebook_Facebook\initSharedSession().
|
protected |
Parses a signed_request and validates the signature.
string | $signed_request | A signed token |
Definition at line 996 of file base_facebook.php.
References $data.
Referenced by sspmod_authfacebook_Facebook\initSharedSession().
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 341 of file base_facebook.php.
BaseFacebook::setApiSecret | ( | $apiSecret | ) |
Set the App Secret.
string | $apiSecret | The App Secret |
Definition at line 267 of file base_facebook.php.
BaseFacebook::setAppId | ( | $appId | ) |
Set the Application ID.
string | $appId | The Application ID |
Definition at line 246 of file base_facebook.php.
BaseFacebook::setAppSecret | ( | $appSecret | ) |
Set the App Secret.
string | $appSecret | The App Secret |
Definition at line 278 of file base_facebook.php.
BaseFacebook::setExtendedAccessToken | ( | ) |
Extend an access token, while removing the short-lived token that might have been generated via client-side flow.
Thanks to http://bit.ly/b0Pt0H for the workaround.
Definition at line 351 of file base_facebook.php.
References $params, and array.
BaseFacebook::setFileUploadSupport | ( | $fileUploadSupport | ) |
Set the file upload support status.
boolean | $fileUploadSupport | The file upload support status. |
Definition at line 308 of file base_facebook.php.
|
abstractprotected |
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 |
|
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 1232 of file base_facebook.php.
|
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 we destroy the session.
$result | array A record storing the error message returned by a failed API call. |
Definition at line 1250 of file base_facebook.php.
References $message, and FacebookApiException\$result.
BaseFacebook::useFileUploadSupport | ( | ) |
DEPRECATED! Please use getFileUploadSupport instead.
Get the file upload support status.
Definition at line 329 of file base_facebook.php.
|
protected |
Definition at line 199 of file base_facebook.php.
|
protected |
Definition at line 167 of file base_facebook.php.
|
protected |
Definition at line 174 of file base_facebook.php.
|
static |
Default options for curl.
Definition at line 133 of file base_facebook.php.
|
static |
Maps aliases to Facebook domains.
Definition at line 153 of file base_facebook.php.
|
staticprotected |
List of query parameters that get automatically dropped when rebuilding the current URL.
Definition at line 144 of file base_facebook.php.
|
protected |
Definition at line 206 of file base_facebook.php.
|
protected |
The data from the signed_request token.
Definition at line 186 of file base_facebook.php.
|
protected |
A CSRF state variable to assist in the defense against CSRF attacks.
Definition at line 191 of file base_facebook.php.
|
protected |
Definition at line 213 of file base_facebook.php.
|
protected |
Definition at line 181 of file base_facebook.php.
const BaseFacebook::SIGNED_REQUEST_ALGORITHM = 'HMAC-SHA256' |
Signed Request Algorithm.
Definition at line 128 of file base_facebook.php.
const BaseFacebook::VERSION = '3.2.2' |
Version.
Definition at line 123 of file base_facebook.php.