By Augusto Guido

Hey, thanks for coming back for part 2. I know it took some time to start writing this second part, it’s just that facebook keeps getting better and keeps taking my time away (don’t tell Conrado).

If I remember correctly in Part 1 we ended up with facebooker installed, configured and running. We even added the facebook connect button and explained how to use some of the great facebooker helpers. As promised in my last post we are going to explain a bit how the magic happens with XFBML, invite friends and publish feed items.

XFBML

Facebook uses XFBML as a way for you to incorporate FBML (Facebook Markup Language, an extension to HTML) into an HTML page on a Facebook Connect site or an iframe application. read more here.

This is a typical XFBML tag, it brings up the profile picture of the user with the uid=”12345″.

What’s happening here? Facebook is turning this into a typicall HTML <img> tag. They do this using a Javascript cross-domain communications library. You can read more here if you are interested. This is all done for you when using Facebooker.

Boring right? Let’s invite some friends to our connect site to keep things more interesting.

Inviting Friends

If you went through the facebooker helpers you are probably thinking about using fb_multi_friend_selector to select friends. Well you are right! We’ll be using that helper, but we will need it inside another helper that is fb_request_form. There’s also another helper that could help us that is fb_multi_friend_request, which is basically the first two together, but we are going to use the first option. Here’s the resulting code:

I don’t want to explain something that’s already out there in many places, I will just describe a bit what’s going on. We put things inside a fb_serverfbml, because we are in a facebook connect site and need users interaction with facebook directly (that is when selecting their friends). The content_for(“invite_user”) is the content that will be show in the fb_request_form. The fb_request_form is a facebook form used when we need to submit information to facebook.

And the fb_multi_friend_selector is the nice facebook like friend selector. You can choose condensed => true to show an ugly smaller one. The exclude_ids => facebook_session.user.friends_with_this_app.map(&:id).join(“,”) is pretty great, it makes the friend selector not to show the friends who are already using our facebook connect site.

Anyway, you can get much more things done, here are some of the facebooker helpers to do anything you like with them ;). And of course the facebook developers wiki is a great place for starting and becoming a guru. I will add in other post the publishing feeds part.

Enjoy!