Facebook SDK for PHP
The Facebook SDK for PHP enables developers to implement a rich set of server-side functionality for accessing Facebook's API. This includes access to all of the features of the Graph API and FQL. It also works alongside the Facebook SDK for Javascript to help you implement Facebook Login.
The SDK is typically used to perform operations as an app administrator, but can also be used to perform operations on behalf of the current session user. By removing the need to manage access tokens manually, the SDK greatly simplifies the process of authentication and authorizing users for your app.
Take a look at Getting Started with the Facebook SDK for PHP for instructions on downloading, installing, and initialization.
PHP SDK Guides
Retrieve a user profile
This example covers getting profile information for someone using your app or site and printing their name, using the Graph API with the PHP SDK.
Share a Link
This example covers posting a link to the timeline using the Graph API with the PHP SDK.
Upload a photo
This example covers uploading a photo using the Graph API with the PHP SDK.
Facebook Class
While most of the functionality of the Facebook SDK for PHP is implemented in the abstract
BaseFacebook
class, the Facebook
class provides a concrete implementation that uses PHP sessions to store user IDs and access tokens. Normally, you will interact with Facebook using this class using the public APIs from BaseFacebook
.BaseFacebook Class
The
BaseFacebook
class 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 subclassed so that you can define how persistent data should be stored for your application. The Facebook
class implements these abstract methods using PHP sessions.api
Call a Graph API method or an FQL Query using the PHP SDK.
destroySession
Destroy the current session.
getAccessToken
Get the current access token being used by the SDK.
getAppId
Get the App ID that the SDK is currently using.
getApplicationAccessToken
Get the access token that should be used for logged out users when no authorization code is available.
getAppSecret
Get the App secret that the SDK is currently using.
getFileUploadSupport
Get whether file upload support has been enabled in the SDK.
getLoginUrl
Get a URL that the user can click to login, authorize the app, and get redirected back to the app.
getLogoutUrl
This method returns a URL that, when clicked by the user, will log them out of their Facebook session and then redirect them back to your application.
getSignedRequest
Get the current signed request being used by the SDK.
getUser
This method returns the Facebook User ID of the current user, or 0 if there is no logged-in user.
setAccessToken
Set the current access token being used by the SDK.
setAppSecret
Set the App secret that the SDK is currently using.
setAppId
Set the App ID that the SDK is currently using.
setExtendedAccessToken
Extends the current access token being used by the SDK to be a long-lived token. This requires an existing valid access token.
setFileUploadSupport
Set file upload support in the SDK.
Abstract methods
These methods are required by any class which extends from
BaseFacebook
such as the Facebook
class we provide.setPersistentData
Stores the given key-value pair, so that future calls to getPersistentData for a given key return the related value.
getPersistentData
Get the stored value for a given key which was set with BaseFacebook::setPersistentData.
clearPersistentData
Clears the stored value for a given key.
clearAllPersistentData
Clears all stored key-value pairs.
No comments:
Post a Comment