The Facebook API is A-OK: Tips for creating Facebook applications
When I set out to create my first Facebook application, I was totally jazzed. Here was the coolest open platform around. Heck, they even had their own tag system. This was going to be so awesome.
I added the developer application and lo and behold: starter code! I had my “hello world” app up and running in no time. This was going to be easy!
That’s when things started to slow down. The Facebook Developer Wiki tends to sprawl a bit, so I ordered some books (a natural reaction for a pushing-40 developer).
Books
I found a couple that I liked: The Facebook Cookbook along with the FBML reference gave the extra narration I needed to fill in the gaps between using the Facebook Markup Language (FBML), the Facebook API and the Facebook Query Language (FQL). In addition to the section on FQL, it contains a good description of the tables available to developers to use in their queries.
Now, if you’re not a book person and don’t want to drop the $26 on Amazon, you can certainly get most of this information clicking around in the Facebook Documentation Wiki. But after awhile, that got frustrating. In particular, I found it difficult to click back and forth between the FQL tables to find what sort of joins I needed to make, and for that matter, if I could even make them at all. I should note here that I’m working on a pretty sluggish network (just trying to pre-empt any “how hard is it to click around a site, you old geezer?”)
Visualizing the Facebook Table Schema
Aside from being too lazy to click around the developer wiki, I like to visualize an application’s available data while I’m developing. To aid in that, I cracked open the closest data diagram tool and whipped up a visual map of the Facebook table schema. Before I forged out on my own, I stumbled upon this Facebook object diagram, but it seemed to be a couple years old and didn’t seem to match the current schema, so I forged ahead with my own version.
Finding a Solid PHP Framework
Now, you can develop Facebook applications in a variety of languages using wrapper objects for Rails, .NET, and Java. However, the Facebook API is native to PHP, which is why I chose to stick with it. I was tempted by the Model, View, Controller (MVC) structure of the Rails framework, but had reservations about ease of deployment and the ability of my hosting provider to support it effectively. Luckily, I found CakePHP.
Cake is an MVC framework for PHP with a robust community of developers with the added benefit of being written in (ding!) PHP so it’s easy to deploy. I’d say that the two drawbacks in comparison to Rails is that PHP doesn’t have the magical almost sentence-like syntax of Ruby and the lack of easy local development with Webrick or Mongrel (you have to do some Apache tinkering on your local machine if you want to do local Cake development). The biggest upside of Cake is that you don’t need a book to deploy your application.
In order to get your Facebook app rolling with CakePHP, you’ll need to configure the Facebook API as a datasource in your Cake instance. I followed Matt Huggins’ article on how to set this up with great success.
Find a Text Editor with a High Level of Awesome
I know, as a developer, you’re probably already clinging to your IDE or text editor of choice. But if you aren’t, allow me to make a few humble suggestions:
For the Mac, TextMate is unbeatable as an editor if you’re willing to pay a little dough.Text Mate has some great bundles for all kinds of languages as well as a Twitter and XMLRPC engine for in-editor tweeting and blogging.
For Windows, you can get the E – Text Editor which is basically an exact port of Text Mate and is very affordable compared to things like Dreamweaver.
If you want to go free, there’s Komodo Edit from the Active State folks. It’s available for Mac, Windows and Linux.
Happy Coding
That’s about all you need aside from some cheap web hosting to get your mult-bazillion dollar Facebook app up and rolling. Have a blast!
Musical Inspiration
Enjoy The Subterranean Facebook Blues — Bob Dylan’s song about Facebook.