The Application Development Platform of Facebook supports a lot of Software Development Kit (SDK), for example, Facebook SDK for Javascript, Facebook SDK for PHP, Facebook SDK for iOS and Facebook SDK for Android. Choose a suitable SDK to develop your Facebook Apps.

In this post, I am going to show how to use SDK for PHP to set up a development environment for Facebook Apps.

Facebook SDK for PHP

The most popular SDK for Facebook Application Development should be Facebook SDK for PHP which supports all the PHP-based web applications. The SDK is open source and is available on GitHub.com website at:

https://github.com/facebook/facebook-php-sdk

The most exciting news of the Facebook SDK for PHP is that it provides a rich set of server-side functionality for accessing Facebook’s server-side API calls. These include all of the features of the Graph API and FQL.

The PHP 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 PHP SDK greatly simplifies the process of authentication and authorizing users for your App.

Note:
You will need an App ID and App Secret Keyto initialize the SDK, which you can obtain from the Facebook App Dashboard as shown in the diagram below:

Set Up Facebook SDK for PHP Development Environment

1. Go to GitHub.com website to download the latest version of SDK for PHP at:

https://github.com/facebook/facebook-php-sdk

The latest version of SDK for PHP at time of writing is v3.1.1.

2. Unzip the download file. You will find three folders (examples, src and tests) as shown below:

3. Open the src directory. You should see a file with filename facebook.php and base_facebook.php.

The facebook.php  and base_facebook.php are the most important files of the download package. It contains a class named Facebook which can be used to connect to the Facebook servers, posting requests as well as some useful functions.

4. To set up the Facebook SDK for PHP Development Environment, simply copy the files from the “src” directory to a directory on the server where you will host your App, for example “fb”.

In the above example, all developing files were saved in MyDomain.com/facebook/pagetab/fb directory of my hosting account.

5. To use the SDK, simply include the facebook.php in a PHP file, for example:

require ‘fb/facebook.php’;

By the way, the example.php file in example folder is a good file to get started and learned.

Now, the Facebook SDK for PHP Development Environment has been set up. In the next post, I will start writing some PHP codes for a App connecting to Facebook servers.