14 June 2007

A small success!

Checking today (‘today’ being the second day of this application being included in the application repository), I see 400+ users, out of which 4 are friends. These past two days have shown exactly what people meant by the Facebook ‘social graph’ and ‘viral distribution’ of applications. I noticed some applications become big time earners overnight, but a small application like my to–do list getting these many users in 2 days is very, very heartening :)

So, now I’m going to have a look at the whole Facebook development scenario:

F8 Platform

The platform, at its heart is a REST based API. You make simple calls to one URL, with the required details, and the server sends back whatever you asked for after running a few checks to see if you “can” get the data you asked for. It’s quite simple that way. There are tokens, session keys (there are two types, more later), API keys and all the regular boobah that you’re used to seeing. However, it gets interesting when you begin to move away from this REST API.

Facebook is one of the first APIs (that I’ve seen in my short stint with webdev) that offers direct access to their SQL tables. Ofcourse, they call it FQL, but the outcome is the same. You select columns, where certain conditions are matched and validated, from some tables. This not only saves time, but reduces server load, since you’re going to the heart of the data instead of being proxy–ed around.

Finally, there’s FBML, which is Facebook’s version of (X)HTML. It offers RDF–type tags which get parsed by Facebook into proper data wrapped in relevant tags. This is used when your application has a profile presence box, and you need to show stuff in it. You update it with FBML using a given function. Or if you want to show editing options for features for your app. It’s quite cool! :)

Static content is cached by Facebook for faster serving (like images, videos etc.), but most of the load is on the developers servers. All processes happen on your servers, and Facebook only acts as a mediator between your server and the user, so that they can control what comes and goes through.

The development

If you know how frameworks and APIs work, this will be familiar grounds. Even if you don’t, you can figure your way out by getting yourself the REST Clients from Facebook. It’s got functions to do everything, and all you need to do is call them. I use the PHP5 Client, but there are clients available for pretty much every major language used for Webdev today.

It’s been a breeze getting the hang of it (thanks to a lot of help from Stephen, as usual), and just having access to such huge amounts of data is amazing. With all coding projects, you have to figure out how to get around some hurdles. For example, the current system allows the authorization token to be passed to only “one” page per app. That means, you can’t call Facebook from any other page, unless you have an infinite session key to pass around. It takes some figuring out, but once you get the hang of it, you can see a pattern emerging. I personally think Facebook should allow choosing custom pages (via. a “next” query string which they use, but don’t allow access to) to which you’d like to redirect to from Facebook. But oh well …

Pretty much all workings with applications will require you to store data of some sort (if it’s a decent to good app). For that, you’ll need to know SQL if you want to work with relational tables. I use Ning at the moment, which offers a different way of storing huge amounts of data. I am adequately adept at SQL though, and plan to brush up on it since I want to move to my own hosting soon enough, and host my apps from there. You will need to know all this to make an effective application. There are workarounds, sureLike the “X Me” application, which didn’t deal with tables in the beginning, but used to constantly read the current markup in the profile box, alter it using regular expressions, and then put it back. For example, if someone would hide an action, it would set it to display:none instead of actually removing it. I got my info from the maker himself :), but I’d suggest you do it the right way.

The documentation is grossly incomplete, but then which documentation isn’t. If you want help, the Developer’s Discussion Group is always there, and people like me who can help you out. There’s also an unofficial IRC room at #facebook on irc.freenode.org. That’s a fabulous place to get info, “if” the people are in a good mood :P

Final thoughts

All in all, it’s not hard making an application for Facebook, and for people who want to start getting their hands dirty with webdev, this is probably the safest and best way to start. You don’t have to looking for data. It’s all there. All you have to do is call for it :) Also, you should be creative. Don’t try to re–invent the wheel and make something that already exists. Your app will get stifled because the other app will already have an established base. There are so many things you can make, it’s not even funny! Just rack your brains a little … ;)

So, I hope I’ve cleared things out, and hope to see someone from my readers come up with a great application for Facebook :) Let me know if you do!

(P.S. — My app users count went up to 403 while writing this article! :P That’s how quickly apps can catch on :) )


Gaby de Wilde said...

hey man, congratz with your app. I had some problems with being called a "face" and having to log in. But from the number of users I see people really are that superficial. hahaha

Anyway, now that I have your face up there it's awfully tempting to code something up.

I can still resist the urge... ok ok will read the documentation....

good luck man.

Aditya said...

Thanks :)

I'm sure you can code up something much better :P You have yourself a new playground :)

Would love to see what you come up with!