ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
|
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... | |
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 | |
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 215 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 852 of file base_facebook.php.
References PHPMailer\PHPMailer\$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 889 of file base_facebook.php.
References $key, PHPMailer\PHPMailer\$params, and $url.
|
protected |
Invoke the old restserver.php endpoint.
array | $params | Method call object |
FacebookApiException |
Definition at line 801 of file base_facebook.php.
References PHPMailer\PHPMailer\$params, and FacebookApiException\$result.
BaseFacebook::api | ( | ) |
Make an API call.
Definition at line 639 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 | base64UrlEncoded string |
Definition at line 1253 of file base_facebook.php.
References $input.
|
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 1266 of file base_facebook.php.
References $input.
|
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 1275 of file base_facebook.php.
References $_COOKIE, and user().
|
staticprotected |
Definition at line 1339 of file base_facebook.php.
|
staticprotected |
Prints to the error log if you aren't in command line mode.
string | $msg | Log message |
Definition at line 1234 of file base_facebook.php.
References Monolog\Handler\error_log().
|
protected |
Lays down a CSRF state token for this process.
Definition at line 734 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 388 of file base_facebook.php.
|
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 753 of file base_facebook.php.
References $code, and PHPMailer\PHPMailer\$params.
BaseFacebook::getApiSecret | ( | ) |
|
protected |
Build the URL for api given parameters.
$method | String the method name. |
Definition at line 1039 of file base_facebook.php.
References $name.
BaseFacebook::getAppId | ( | ) |
Get the Application ID.
Definition at line 246 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 725 of file base_facebook.php.
BaseFacebook::getAppSecret | ( | ) |
|
protected |
Get the base domain used for the cookie.
Definition at line 1164 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 680 of file base_facebook.php.
|
protected |
Returns the Current URL, stripping it of known FB parameters that should not persist.
Definition at line 1181 of file base_facebook.php.
References GuzzleHttp\Psr7\$protocol.
BaseFacebook::getFileUploadSupport | ( | ) |
Get the file upload support status.
Definition at line 308 of file base_facebook.php.
|
protected |
Definition at line 1134 of file base_facebook.php.
References $_SERVER.
Referenced by sspmod_authfacebook_Facebook\initSharedSession().
|
protected |
Definition at line 1141 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 620 of file base_facebook.php.
References PHPMailer\PHPMailer\$params.
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 569 of file base_facebook.php.
References PHPMailer\PHPMailer\$params.
BaseFacebook::getLogoutUrl | ( | $params = array() | ) |
Get a Logout URL suitable for use with redirects.
The parameters:
array | $params | Provide custom parameters |
Definition at line 598 of file base_facebook.php.
References PHPMailer\PHPMailer\$params.
|
protected |
Parses the metadata cookie that our Javascript API set.
Definition at line 1306 of file base_facebook.php.
References $_COOKIE, and $metadata.
|
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 668 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 479 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 657 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 1119 of file base_facebook.php.
References $name, PHPMailer\PHPMailer\$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 498 of file base_facebook.php.
|
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 416 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 709 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 515 of file base_facebook.php.
References $default, and $user.
|
staticprotected |
Definition at line 1332 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 835 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 915 of file base_facebook.php.
References PHPMailer\PHPMailer\$params, FacebookApiException\$result, and $url.
|
protected |
Makes a signed_request blob using the given data.
array | The data array. |
Definition at line 1019 of file base_facebook.php.
References $data.
Referenced by sspmod_authfacebook_Facebook\initSharedSession().
|
protected |
Parses a signed_request and validates the signature.
string | $signed_request | A signed token |
Definition at line 989 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 331 of file base_facebook.php.
BaseFacebook::setApiSecret | ( | $apiSecret | ) |
Set the App Secret.
string | $apiSecret | The App Secret |
Definition at line 257 of file base_facebook.php.
BaseFacebook::setAppId | ( | $appId | ) |
Set the Application ID.
string | $appId | The Application ID |
Definition at line 236 of file base_facebook.php.
BaseFacebook::setAppSecret | ( | $appSecret | ) |
Set the App Secret.
string | $appSecret | The App Secret |
Definition at line 268 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 341 of file base_facebook.php.
References PHPMailer\PHPMailer\$params.
BaseFacebook::setFileUploadSupport | ( | $fileUploadSupport | ) |
Set the file upload support status.
boolean | $fileUploadSupport | The file upload support status. |
Definition at line 298 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 |
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 1206 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 319 of file base_facebook.php.
|
protected |
Definition at line 189 of file base_facebook.php.
|
protected |
Definition at line 157 of file base_facebook.php.
|
protected |
Definition at line 164 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 143 of file base_facebook.php.
|
protected |
Definition at line 196 of file base_facebook.php.
|
protected |
The data from the signed_request token.
Definition at line 176 of file base_facebook.php.
|
protected |
A CSRF state variable to assist in the defense against CSRF attacks.
Definition at line 181 of file base_facebook.php.
|
protected |
Definition at line 203 of file base_facebook.php.
|
protected |
Definition at line 171 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.