Monday, 2 March 2009

Facebook code

I have been playing around with trying to develop facebook applications. Here is some sample code from facebook. It makes it seem so easy right? Not:

Follow the simple steps below to create a working skeleton for your Application.
Step 1: Download Facebook's PHP Library

Extract this archive into a directory on your hosting server where you can host and run PHP code (let's call this directory MY_DIR):

$ wget ''
$ tar -xzvf facebook-platform.tar.gz
$ cp facebook-platform/client/facebook*.php MY_DIR

Step 2: Create An 'index.php' File

It should look like this, and should also go into MY_DIR:


// Greet the currently logged-in user!
echo "

Hello, !


// Print out at most 25 of the logged-in user's friends,
// using the friends.get API method
echo "

$friends = $facebook->api_client->friends_get();
$friends = array_slice($friends, 0, 25);
foreach ($friends as $friend) {
echo "
echo "


Step 3: Test Your Application

You've almost finished!

We just need you to specify the URL for your application. Edit Settings for your app and choose a Canvas Page URL.

No comments:

Post a Comment