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.
zombat
source share