Can FBML be used within an iFrame Facebook app? - facebook

I am working on writing a small Facebook application just for fun and learning. Unfortunately, the Facebook developer documentation, wiki, and samples leave much to be desired.
If my application is an iFrame app (PHP), can I use FBML within the page or do I need to use the XFBML? If I need to use XFBML, is there a repository of snippets somewhere that I could look through?
I am looking to add a friend selector box. For example, welcome to the app, pick an object, send it to 20 friends.
You would think a friend selector would be a stock component for Facebook apps, but apparently not.
I can use FBQL and CSS to define my own, but wouldn't standards and consistency be nice?
Is there a definitive, from the ground up, easy to follow Facebook app developers tutorial that covers the FBML tags, the XFBML tags and what goes where with examples?

I think in every answer I make to a Facebook question, I pretty much mention that "Facebook documentation sucks, so don't feel bad if you can't find something."
The answer is yes, you can definitely use FBML in an IFrame application. I do it routinely. Facebook is blurring 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 rendered via the Facebook Connect javascript libraries. Because of this, you see a bit of a delay before an FBML control is rendered, but generally this isn't a big problem.
I'll give you an example of loading a friend selector straight from one of my IFrame apps. You'll see that it's surrounded by fb:serverfbml tags, which you need to render several of the more complicated FBML tags. The FBML items that don't need a fb:serverfbml tag around them are listed on the XFBML wiki 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>
Escaping quotes gets a bit tricky with all the nested tags, so you have to watch that. You can see my example is from a PHP app, and I left an htmlspecialchars() escape call in there just for illustrative purposes (even though that particular string doesn't need escaping).
Anyhow, if you've got Facebook Connect already installed for your IFrame app, then this should work with a bit of tweaking. If you don't have Facebook Connect going yet, then follow the Rendering XFBML instructions on the XFBML wiki page.

Related

Alternate to <fb:redirect url="http://www.mywebsite.com/" />

My app is my website so I used to put this code in my canvas page so I redirect my users to my website :
<fb:redirect url="http://www.mywebsite.com/" />
but since fbml has been deprecated and will not be supported anymore soon I need to use another method to redirect my users .. is the following code the best I can do or there is another way?
<script type='text/javascript'>top.location.href = 'http://www.mywebsite.com/';</script>
That's right. You can only do a top.location since you are inside an iframe. See more here: Redirect from Facebook canvas page to website

Is fb:multi-friend-selector deprecated?

I have a page in my website to invite Facebook friends to use my website and the code is pretty standard stuff
<fb:serverFbml style="width: 755px;">
<script type="text/fbml">
<fb:fbml>
<fb:request-form ....
<fb:req-choice />
>
</fb:request-form>
<fb:multi-friend-selector .../>
</fb:fbml>
</script>
</fb:serverFbml>
As far as what I understand, because I am including FB JS SDK, it interprets the XFBML tags and includes the appropriate html for the same (which is interpreted by the browser).
I hear that FBML is being deprecated. I am assuming that this will not affect the XFBML tags, rt? Can someone please confirm? I am confused because all these tags have been listed in FB documentation under Advanced Topics › Legacy FBML › fb:serverFbml.
I also have other tags in various other pages like <fb:profile-pic>, <fb:name>, <fb:title>, <fb:iframe>, <fb:google-analytics> Should I be migrating them to their HTML equivalent?
Is there some documentation on how to go about doing this? Any inputs is highly appreciated
Thanks.
fb:multi-friend-selector never had XFBML versions but only FBML which isn't the same since FBML only works in application canvas and only for apps that use FBML (not an iframe)
Cite from FBML documentation
We are deprecating FBML. On Jan 1, 2012: FBML will no longer be supported on Platform. June 1, 2012: FBML apps will no longer work. All FBML endpoints are removed. If you are building a new application on Facebook.com, please implement your application using HTML, JavaScript and CSS. You can use our JavaScript SDK and Social Plugins to embedded many of the same social features available in FBML.
Update:
You still can use it with FB.XFBML.parse method of JavaScript SDK.
In your case looks like you should move fb:multi-friend-selector to be within fb:request-form (like it shown on fb:request-form documentation.
But I strongly suggest using Requests Dialog with JavaScript SDK instead of FBML tags
Update 2:
While not officially confirmed (yet) I'll allow myself to speculate on this a bit. Probably every FBML tags will be removed and fb:serverFbml will not be parsed by JS-SDK after June 1, 2012.
You can try to ask about this on Quora (with a big change to get response from one of officials

How to add google docs forms to facebook fan page?

I'd like to place my google docs form(for newsletter sign-up) on my facebook page.
using this tutorial I was able to create an app, but no content showed http://www.hyperarts.com/blog/adding-iframe-application-to-facebook-fan-page/
So I wanted to know if there was another way of doing this, or anyway of doing this at all.
I had the same issue with using the iframe that google docs give you and using the url for the application tab on Facebook. The resulting facebook page is blank.
What I did to resolve this is whip up a simple html file that does the embedding from google and placed it on my (ssl encrypted) server. Then I used the url to that file as the application tab URL in my facebook app. Viola it worked.
Is Facebook not allowing embeds from docs.google.com? There's a simple workaround.
Here's the code from my html file on my server with the formkey mangled to protect privacy.
<html>
<body>
<iframe src="https://docs.google.com/spreadsheet/embeddedform?formkey=dGhOU" width="500" height="780" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>
</body>
</html>
There's a php class that i've been using. It provides functionality to capture form elements into a google doc.
That's a possibility but requires a larger learning curve if you're not familiar with PHP:
http://code.google.com/p/php-form-builder-class/

Facebook Send Requests

How are we supposed to send requests on Facebook if Facebook is in the process of deprecating FBML? Is there another way?
Found it! (Well, I didn't, but my friend did.)
Facebook Requests Dialog - JavaScript SDK
Facebook was hiding it! :)
It's really cool. Much better than old requests. You can store custom data in them and access it through the Graph API!
Note to self: "Read the documentation thoroughly."
Currently there is no other way..Facebook is updating the graph api and message part.So you can use FBML itself for the current use.You can use request-form and multi-friend-selecto to send the request.
<fb:request-form
action="start.htm"
method="POST"
invite="true"
type="sample network"
content="This network is the best place on Facebook for viewing, sharing and giving
friends the highest quality stuff. Join me on this network!
<fb:req-choice url='http://www.facebook.com/login.php?api_key=<c:out value='${apiKey}' />'
label='Check out this network!' />
">
<fb:multi-friend-selector
showborder="false"
actiontext="Invite your friends to this network."
exclude_ids="<c:out value='${appUserFriends}' />"
max="20" />
According to this part of the documentation it will be possible to achieve through dialogues.
Please note, we are in the process of moving this functionality to Platform Dialogs which will remove the requirement for the use of FBML.
At the moment I couldn't find anything about inviting friends yet (Friend Dialog is misleading - it's about adding new friends) but I suggest you keep an eye on updates here.
I would say use FBML for now because it will take some time before it is officially deprecated (it was announced a long time ago) but check up on the new methods so that you can implement it as soon as possible.
And there is the option of the send button as a tag
http://developers.facebook.com/docs/reference/plugins/send/
This is not deprecated right???

how to use facebook comments plugin into facebook page

We have a Face book page.We add a custom FBML tab.Now we want to add Comment Face book plugin.I tried to add an script what i got from Face book Social Plug in.The code is
<div id="fb-root"></div><script
<src="http://connect.facebook.net/en_US/all.js#appId=178089302222317&amp;xfbml=1"></script><fb:comments numposts="10" width="425"
publish_feed="true"></fb:comments>
After that i put this script to custom FBML page but its not reflecting any thing please suggest to solve this issue.
Thanks in advance.
You should start over and not use FBML but use an iframe instead.
You are trying to create an app on a page tab. To do this take a look at the FB dev site and it shows you how to get started with an iframe based app and then how to get that to work on a page tab.
https://developers.facebook.com/docs/guides/canvas/#tabs
Once you move to iframes you can use all of the social plug-ins and other advanced features like the Graph API.
<fb:comments xid="some_unique_id_doesnt_matter_what" canpost="true" candelete="false" publish_feed="true" numposts="10" returnurl="http://facebook.com/YOURPAGE">
<fb:title>Headline</fb:title>
</fb:comments>
this is what you are looking for.. your code doesnt work in FBML, yours is XFBML
<fb:title>
is optional