Site icon Web Niraj

Facebook API: Setting up the Facebook PHP SDK 4.0.x

One of the most common questions I get regarding Facebook’s new PHP SDK v4.0.x is how to set it up and get started. My previous tutorial covers how to start using the SDK, but not how to arrange your files and the SDK itself – this tutorial attempts to bridge the gap.

After downloading the latest version of the Facebook PHP SDK (currently v4.0.7), you need to extract the source code and copy them into your application folder. The best way to do this is to copy the contents of the src folder into your application folder. The src folder contains a single Facebook folder with all the PHP files you need to use the SDK. You only need to copy the Facebook folder from here.

A typical application setup can be as follows:

See the gist on github.

If you use a PHP Framework like CodeIgnitor, you should copy the Facebook folder to the /application/libraries folder instead. For example:

See the gist on github.

Once the basic file structure is set up, you can follow the “Getting Started” tutorial to find out how to start building Facebook Apps.

Exit mobile version