Can i use FBML in iFrame Facebook app?

I am working on writing a small Facebook application just for fun and learning. Unfortunately, developer documentation, wikis, and samples for Facebook developers are poor.

If my application is an iFrame (PHP) application, can I use FBML on the page or do I need to use XFBML? If I need to use XFBML, is there somewhere a repository of snippets that I could view somewhere?

I am looking to add a friend selection window. For example, welcome to the application, select an object, send it to 20 friends.

You might think that a friend’s assistant would be a stock component for Facebook apps, but apparently not.

I can use FBQL and CSS to define my own, but would not be standards and consistency?

Is there a final, right from the start, easy to follow Facebook application developer guide that covers FBML tags, XFBML tags, and what happens with examples?

+6
facebook
source share
1 answer

I think that in every answer I ask to the Facebook question, I almost mentioned that "the documentation on Facebook is crap, so don’t feel bad if you can’t find something."

Answer: yes, you can definitely use FBML in an IFrame application. I do it regularly. Facebook blurs the lines between IFrame apps and FBML apps with XFBML, which is great. Basically, XFBML is just regular FBML, except that it is parsed and displayed through the Facebook Connect javascript libraries. Because of this, you see a slight delay before rendering the FBML control, but this is usually not a big problem.

I will give you an example of loading a friends selector directly from one of my IFrame applications. You will see that it is surrounded by fb: serverfbml tags , which you need to display a few more complex FBML tags. FBML elements that do not need the fb: serverfbml tag around them are listed on the XFBML page.

Anyway, some code:

<fb:serverfbml style="width: 650px;"> <script type="text/fbml"> <fb:fbml> <fb:request-form action="http://my.app.com/invite/sent" method="POST" invite="true" type="My App Name" content="You should use My App Name. All the cool kids are doing it. <fb:req-choice url='http://apps.facebook.com/my-app' label='<?php echo htmlspecialchars("That sounds sweet!",ENT_QUOTES); ?>' /> " > <fb:multi-friend-selector showborder="false" actiontext="Invite your friends to use My App Name." exclude_ids="1234556,465555" rows="3" /> </fb:request-form> </fb:fbml> </script> </fb:serverfbml> 

Dropping quotes becomes a bit complicated with all nested tags, so you should watch this. You can see that my example is from a PHP application, and I left the htmlspecialchars() escape call there for illustrative purposes only (even if this particular line does not need escaping).

In any case, if you already have the Facebook Connect application installed for your IFrame application, this should work with a small amount of settings. If you don't already have Facebook Connect, follow the Rendering XFBML instructions on the XFBML page.

+8
source share

All Articles