Base64 encoding that doesn't need to be urlencode()ed.
Exactly the same as base64_encode except it uses
_ instead of /
static
void
base64UrlDecode
(String $input)
-
String
$input: base64UrlEncodeded string
Prints to the error log if you aren't in command line mode.
static
void
errorLog
(String $msg)
Generate a signature for the given params and secret.
static
String
generateSignature
(Array $params, String $secret)
-
Array
$params: the parameters to sign
-
String
$secret: the secret to sign with
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
Facebook
__construct
(Array $config)
-
Array
$config: the application configuration
Make an API call.
the
api
(Array $params)
-
Array
$params: the API call parameters
Returns something that looks like our JS session object from the signed token's data
TODO: Nuke this once the login flow uses OAuth2
Array
createSessionFromSignedRequest
(Array $data)
-
Array
$data: the output of getSignedRequest
Gets a OAuth access token.
String
getAccessToken
()
Get the API Secret.
String
getApiSecret
()
Build the URL for api given parameters.
String
getApiUrl
($method $method)
-
$method
$method: String the method name.
Get the Application ID.
String
getAppId
()
Get the base domain for the Cookie.
String
getBaseDomain
()
Returns the Current URL, stripping it of known FB parameters that should not persist.
String
getCurrentUrl
()
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
String
getLoginStatusUrl
([Array $params = array()])
-
Array
$params: provide custom parameters
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"
String
getLoginUrl
([Array $params = array()])
-
Array
$params: provide custom parameters
Get a Logout URL suitable for use with redirects.
The parameters:
- next: the url to go to after a successful logout
String
getLogoutUrl
([Array $params = array()])
-
Array
$params: provide custom parameters
Get the session object. This will automatically look for a signed session sent via the signed_request, Cookie or Query Parameters if needed.
Array
getSession
()
The name of the Cookie that contains the session.
String
getSessionCookieName
()
Get the data from a signed_request token
String
getSignedRequest
()
Build the URL for given domain alias, path and parameters.
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
Get the UID from the session.
String
getUser
()
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.
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
Parses a signed_request and validates the signature.
Then saves it in $this->signed_data
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
Set the API Secret.
void
setApiSecret
( $apiSecret, String $appId)
-
String
$appId: the API Secret
-
$apiSecret
Set the Application ID.
void
setAppId
(String $appId)
-
String
$appId: the Application ID
Set the base domain for the Cookie.
void
setBaseDomain
(String $domain)
-
String
$domain: the base domain
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.
void
setCookieFromSession
([Array $session = null])
-
Array
$session: the session to use for setting the cookie
Set the Cookie Support status.
void
setCookieSupport
(Boolean $cookieSupport)
-
Boolean
$cookieSupport: the Cookie Support status
Set the file upload support status.
void
setFileUploadSupport
( $fileUploadSupport, String $domain)
-
String
$domain: the base domain
-
$fileUploadSupport
Set the Session.
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.
Get the Cookie Support status.
Boolean
useCookieSupport
()
Get the file upload support status.
String
useFileUploadSupport
()
Validates a session_version=3 style session object.
Array
validateSessionObject
(Array $session)
-
Array
$session: the session object
Invoke the Graph API.
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
Make a OAuth Request
the
_oauthRequest
( $url, Array $params, String $path)
-
String
$path: the path (required)
-
Array
$params: the query/post data
-
$url
Invoke the old restserver.php endpoint.
the
_restserver
(Array $params)
-
Array
$params: method call object