The Facebook SDK for PHP provides a rich set of server-side functionality for accessing Facebook's server-side API calls such as the Graph API and FQL. It also works alongside the Facebook SDK for Javascript to help you implement Facebook Login.
Take a look at the Getting Started guide for full information about features and usage.
To install the SDK, first download the source from GitHub.
Next, extract the package and copy the files from the src/ directory to a directory on the server where you will host your app, for example php-sdk. Then, just include php-sdk/facebook.php wherever you want to use the SDK. You use the SDK by instantiating a new Facebook object with, at a minimum, your app id and app secret:
require_once("facebook.php");
$config = array();
$config['appId'] = 'YOUR_APP_ID';
$config['secret'] = 'YOUR_APP_SECRET';
$facebook = new Facebook($config);
For more information see the Getting Started guide.
Call a Graph API method or an FQL Query using the PHP SDK.
Get the current access token being used by the SDK.
Get the App secret that the SDK is currently using.
Get the App ID that the SDK is currently using.
Returns a URL based on the user’s login status on Facebook.
Get a URL that the user can click to login, authorize the app, and get redirected back to the app.
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.
Get the current signed request being used by the SDK.
This method returns the Facebook User ID of the current user, or 0 if there is no logged-in user.
Set the current access token being used by the SDK.
Set the App secret that the SDK is currently using.
Set the App ID that the SDK is currently using.
Set file upload support in the SDK.
Get whether file upload support has been enabled in the SDK.
Get the object that is the result of the error or exception returned by the server.
Get the type for the error or exception, e.g. OAuthException.