My First Facebook app

user-pic
| Comment

Intrigued by the idea of developing a Facebook app to generate large amounts of income from the millions of Facebook users hitting my app, I decided to give it a try. It was surprisingly easy to get the basics up and running. The documentation provided by Facebook could use some work, but it is still better than most.

I started out by building the "Hello World" equivalent of a Facebook application. Basically, it is a page on facebook that shows five facebook friends who are currently logged in to the site. My application is a take on example code given to you by Facebook when you register your application with them.

You can try it out here

This is a screenshot:

facebook.JPG

Here are a few links that helped me out:

Facebook Cookbook -These guys have a few very detailed, yet simple examples to follow.

Nettuts - This guy show the basics of getting your first app up and running.

Facebook Developers Wiki - Great resource for developing apps and learning the API.

The next step is to come up with an idea that would have a plausible business impact... for me that is.

Here is the code.

<?php
// Copyright 2007 Facebook Corp. All Rights Reserved.
//
// Application: yourappname
// File: 'index.php'
// This is a sample skeleton for your application.
//

require_once 'facebook.php';

$appapikey = 'yourappkey';
$appsecret = 'yourappsecret';
$facebook = new Facebook($appapikey, $appsecret);
$user_id = $facebook->require_login();

// Greet the currently logged-in user!
echo "<p>Hello, <fb:name uid=\"$user_id\" useyou=\"false\" />!</p>";

// Print out at most 25 of the logged-in user's friends,
// using the friends.get API method
echo "<div style=\"width: 500px;\">";

$friends = $facebook->api_client->friends_get();
$friends = array_slice($friends, 0, 5);
foreach ($friends as $friend) {
echo "<span style=\"float: left; width: 50px; margin-right: 10px;\">";
echo "<br><fb:name uid=\"$friend\" firstnameonly=\"true\"/>";
echo "<br><fb:profile-pic uid=\"$friend\" linked=\"true\" /></span>";

}
echo "</div>";


comments powered by Disqus  

Enter your email address:

Delivered by FeedBurner