Thursday, July 22, 2010

An Introduction FBML: (Facebook Markup Language)

I thought it would be a good idea to go over some of the basics for using FBML. While its not difficult to implement, it can be a little confusing if you’re new to programming or you’ve not programmed with this language before.

For starters, FBML stands for Facebook Markup Language and it works a lot like HTML. Honestly, the biggest difference between the two is that you do not need to include , and tags. Facebook applications rendered with FBML are essentially extensions of the page already, so those tags are already included on the page. Also, depending on what you want your application is or will do; you may not want to use FBML.

So when should you use FBML? For one, if you plan to work on Facebook a lot it can be useful to know a little something about it so you’re prepared for anything. FBML is also very useful for applications that are not external websites and for those that aren’t going to be anywhere else.

What about using iframe? You should use iframe if you already have an external website up and running and simply want to put it on Facebook, too. If you’ve got a lot of Javascript already in place, transforming it into FBJS (Facebook Javascript) will be a hassle. Javascript does not work in an FBML canvas application until it’s been transformed to FBJS.

Facebook suggests you use iframe if you are new to programming; I disagree completely. I find FBML to be far less complex for new users. Using FBML extends far beyond the simple connection with HTML. Facebook utilizes their own Javascript and Ajax objects, both of which are very simple to use, but those will be covered in later posts. Simply put, FBML is much friendlier to new users than iframe will be.

Now, there are a few things you can’t do in FBML that you can with HTML… well, a lot of things. This page in the Facebook Developer Wiki covers all the different tags you can and can’t use here and there. Another thing, if you need a tag that isn’t listed as available there don’t use FBML.

New programmers aren’t going to use a lot of complex HTML tags so FBML doesn’t hurt them there, plus you don’t have to deal with sessions in FBML (Facebook handles it for you). That’s half of why I recommend FBML to new developers. It can hurt experienced developers though, as it may remove some functionality from your applications. It’s also a little odd to go from something you’ve known for quite a while and switch gears to something different. A minor inconvenience in FBML is that you must specify the full web address to items with the ‘src’ attribute (though its good practice to do that in any language).

So what gives an edge, or any for that matter, over good ol’ HTML? It’s simplicity. There are a TON of FBML tags you can add into your application, many of which are not supported outside of an FBML canvas application. Many of these tags add a lot of functionality to your applications. Take a look for yourself.


The other half of why I recommend FBML to new developers? Facebook has essentially “dumbed down” Ajax for one. They’ve simplified Javascript, but the Ajax Facebook utilizes is one of the simplest and easiest tools to learn and use. I find this a great way to introduce Ajax to new developers. At a later date when those developers move on to websites outside of Facebook, they already understand a little bit about how Ajax works and it’s that much easier to learn. All in all, I tend to think of FBML as a “gateway language”.

So let’s recap:


Who should use FBML?

  • Developers new to programming.
  • Developers who only plan to use their application on Facebook.
  • Developers with simple applications.

Who should use iframe?

  • Developers who already have an external website up containing the application content.
  • Experienced developers.
  • Developers who plan to expand to other social networking sites with their application.
  • Developers with complex applications.


No comments:

Post a Comment