Relay #70, Panel F

don't just know technology, understand it

Saturday, December 15, 2007

Creating a Facebook App

I wrote the following in response to a question on Yahoo Answers, however I wasn't able to post it due to technical difficulties, so rather than waste my 4 minutes I'll put it here in hopes that it will be googled and help someone else one day.

Q: I want to make a facebook (and now bebo) App...Help?
I have enjoyed facebook apps for a while and as of a few days ago they came on bebo....both of which I have...
I want to make my own app....how can I....and any ideas?

A: First things first, you've got to have an idea. Fortunately (or unfortunately) 99% of the applications on Facebook are mild distractions that serve no real function, so if you want to get into that space, you app doesn't have to be ground breaking. However being in the other 1%, which will take thought, planning and well written code, will most likely give your app longevity long after the viral effect has run its course.

To do a Facebook app, you will most likely need a server that will host it. Facebook will not host your application, they will only give you access to the Facebook platform though an API (authenticate users, get a user's friends, etc.), and then list your app in their directory.

Depending on the development platform available on your hosting server, your programming language of choice, and available APIs (official or third party), you will have to decide on what language your Facebook app will be. The vast majority of the apps are currently done in PHP. Knowing this, it's probably a good idea to stick with that language unless you have a salient objection as this will enable you to get great support on the development forums.

Once you have your idea, your server, and have decided on a development platform, you're next step is to add the Developer application to your list of installed apps. You must have this installed in order to access the needed developer resources. After adding the application you will request an API Key. This is what will allow you to make calls to the Facebook API and leverage the platform. It is also mandatory that your application make use of the Facebook platform in order to be listed in their application directory.

Next you can download their example code that will give you the basics on developing a facebook application, which could be broken down as:

-Check if the user is logged in: If not, send user to log in page
-Check if user has the application installed: If not, send user to add application page
-Load default application page (In Facebook this is called your Canvas page)

You can take that skeletal code and start mapping your idea against to your application.

You will have to become familiar with some new concepts to create a Facebook application that fully utilizes the platform.

1) FBML
2) FBJS
3) FQL
4) The Facebook API

FBML is the Facebook Markup Language. It's a special markup language, just like XHTML, with some additional tags which basically saves you a lot of work in completing common tasks, for example, selecting a friend or friends from a list.

FBJS is the Facebook flavour of Javascript. It has a subset of the functionality of actual Javascript with the limitations imposed to protect users of your application. (please keep in mind though that your application can extend outside of the Facebook world where you will not have limitations of Javascript use and afterwards you can forward your users to the original Facebook Canvas page.

FQL (presumably Facebook Query Language) allows you to query Facebook for data in the same way you would query a relational database with SQL. You can check out the resources below for more information.

The Facebook API is the heart of any Facebook app as this is what really allows you to hook into the platform. Check out the resources below for more information of the capabilities of the API.

What I have outlined is a very high level synopsis of what it takes to have a Facebook app. You will have to (or at least you should) do some additional reading in order to fully appreciate the intricacies involved, but once you've done it once, you could churn out a new app every few hours.

Happy coding.


Resources: http://wiki.developers.facebook.com/index.php/Main_Page
http://forum.developers.facebook.com/

Labels: , , ,