Any success with FBML in iframe + force_mode=fbml?

Jan 8, 2008 at 3:20 AM
Hello,
my application is an iFrame. I want to use FBML in it. I used the forcemode=fbml parameter: http://www.domain.bet/Facebook.aspx?fbforce_mode=fbml

My code:
...
using System.Collections.ObjectModel;
using Facebook;
using Facebook.Entity;
using Facebook.WebControls;

public partial class FacebookPage : Facebook.WebControls.CanvasFBMLBasePage
{

Facebook.Components.FacebookService _fbService = new Facebook.Components.FacebookService();
private const string FACEBOOK_APPKEY = "xxxxxxxxx";
private const string FACEBOOK_SECRET = "xxxxxxxxx";

string userId = string.Empty;

protected void Page_Load(object sender, EventArgs e)
{
base.Api = FACEBOOK_APPKEY;
base.Secret = FACEBOOK_SECRET;
base.Page_Load(sender, e);


fbService.ApplicationKey = FACEBOOKAPPKEY;
fbService.Secret = FACEBOOKSECRET;
_fbService.IsDesktopApplication = false;

string sessionKey = Request.QueryString"fb_sig_session_key" as String;

userId = Request.QueryString"fb_sig_user" as String;

if (!String.IsNullOrEmpty(userId))
{
_fbService.SessionKey = sessionKey;
_fbService.UserId = userId;
User user = _fbService.GetUserInfo();
...
}

Label1.Text = "<fb:name uid=\"528263296\" />";
}

The FBML is not interpreted. Am I missing something?

Thank you
Jan 8, 2008 at 6:08 PM
I have the same problem making a invitation page.
Jan 8, 2008 at 9:03 PM
I have successfully made an invitation page using the fbforcemode querystring. One thing that tripped me up is that you have to be testing on an externally facing machine. While iframes can load if the dns resolves on your local machine, fbml is loaded by the facebook servers, so has to be accessible to them.

Also, it's not entirely clear from your pasted code if you have the <fb:fbml> and </fb:fbml> tags on your page. If not, you'll need those.

You might also view source on the page after it loads. If you're listed as a developer for the app in facebook, it'll sometimes put error info in a comment in the html page if it's having problems parsing your fbml.

Hope that helps!
Jan 10, 2008 at 3:33 AM

mharper wrote:
I have successfully made an invitation page using the fbforcemode querystring. One thing that tripped me up is that you have to be testing on an externally facing machine. While iframes can load if the dns resolves on your local machine, fbml is loaded by the facebook servers, so has to be accessible to them.

Also, it's not entirely clear from your pasted code if you have the <fb:fbml> and </fb:fbml> tags on your page. If not, you'll need those.

You might also view source on the page after it loads. If you're listed as a developer for the app in facebook, it'll sometimes put error info in a comment in the html page if it's having problems parsing your fbml.

Hope that helps!


Hello,
I tried to simply the problem. I now have 1 html page with this code only:
<fb:fbml><fb:name uid="xxxx" /></fb:fbml>

(xxx is replaced by my valid UID)

It worksfin in the FBML test console.

But when I try this page on Facebook, it does not work. I set the page as FBML as well, no difference. When I look at the source of the iframe, I see <fb:fbml><fb:name uid="xxxx" /></fb:fbml> and nothing else!
Jan 10, 2008 at 5:33 PM
It sounds like you're not getting into fbml mode then - it's still acting like an iframe. I just noticed in your first message, you have a typo on the force mode querystring, it should be fbforcemode=fbml - you're missing the first underscore. That's likely the problem, if you're putting it that way on the actual querystring.
Jan 11, 2008 at 3:46 AM

mharper wrote:
It sounds like you're not getting into fbml mode then - it's still acting like an iframe. I just noticed in your first message, you have a typo on the force mode querystring, it should be fbforcemode=fbml - you're missing the first underscore. That's likely the problem, if you're putting it that way on the actual querystring.


Hello,
thanks for replying.

This was a typo in my post,not in facebook.

Here is waht I filled in for the application:
  • Callback url: http://www.xxx/Facebook.aspx?fb_force_mode=fbml
  • Canvas Page URL: Use iFrame

Facebook.aspx:
{"<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Facebook.aspx.cs" Inherits="FacebookPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Facebook</title>
</head>
<body>
<form id="form1" runat="server">
<div>
...String: <asp:Label ID="headers" runat="server" Text="Label"></asp:Label></p>
</div>
</form>
<fb:fbml>
<fb:name uid="yyyy" />
<fb:request-form method="POST" action="default.aspx" invite="true" type="My App" content="Get started with MyApp! <fb:req-choice url="http://apps.facebook.com/myapp/default.aspx" label="Confirm" />">
<fb:multi-friend-selector showborder="false" rows="5" max="20" actiontext="Invite your friends to use MyApp.">
</fb:request-form>
</fb:fbml>
</body>
</html>"}
Jan 11, 2008 at 2:36 PM
When using fbml, you can only have fbml on the page, so your example should look more like:

Facebook.aspx:
{"<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Facebook.aspx.cs" Inherits="FacebookPage" %>
<fb:fbml>
<fb:name uid="yyyy" />
<fb:request-form method="POST" action="default.aspx" invite="true" type="My App" content="Get started with MyApp! <fb:req-choice url="http://apps.facebook.com/myapp/default.aspx" label="Confirm" />">
<fb:multi-friend-selector showborder="false" rows="5" max="20" actiontext="Invite your friends to use MyApp.">
</fb:request-form>
</fb:fbml>"}

Visual studio will complain about there being not enough html tags, and no form, but it should still compile okay.
Jan 13, 2008 at 1:36 PM
Hi, i have the same problem, I don¡t know what's wrong

this the code aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EnviarEquipo.aspx.cs" Inherits="EnviarEquipo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<fb:fbml>
<fb:request-form method="POST" action="VideosEquipos.aspx" invite="true"
type="Soyhinchade..."
content="Vos, ¿Hincha de quien sos? <fb:req-choice url="http://apps.facebook.com/soyhinchade/" label="Confirm" />">

<fb:multi-friend-selector showborder="false" rows="5" max="20"
actiontext="Invitá a tus amigos y conoce de quien son hinchas.">
</fb:request-form>

</fb:fbml>
</body>
</html>

and this the code behind:

public partial class EnviarEquipo : CanvasIFrameBasePage
{
//Facebook.Components.FacebookService _fbService = new Facebook.Components.FacebookService();
private const string FACEBOOKAPIKEY = "xxxxxxxxxxxx"; // From the Facebook application page
private const string FACEBOOK_SECRET = "xxxxxxxxxxxx"; // From the Facebook application page

new protected void Page_Load(object sender, EventArgs e)
{
base.Api = FACEBOOKAPIKEY;
base.Secret = FACEBOOK_SECRET;
base.Page_Load(sender, e);
if (!IsPostBack)
{
//Facebook.Entity.User usuario = this.FBService.GetUserInfo();
//this.Response.Write(usuario.UserId.ToString());
this.FBService.ApplicationKey = FACEBOOKAPIKEY;
this.FBService.Secret = FACEBOOK_SECRET;
this.FBService.IsDesktopApplication = false;
string sesionKey = Request.QueryString"fb_sig_session_key" as string;
string userId = Request.QueryString"fb_sig_user" as String;
if (!String.IsNullOrEmpty(userId))
{
this.FBService.SessionKey = sesionKey;
this.FBService.UserId = userId;
Facebook.Entity.User user = this.FBService.GetUserInfo();
}
}
}
}
Jan 17, 2008 at 1:44 PM
Edited Jan 17, 2008 at 3:05 PM
After hours and hours of frustration without being able to get fbforcemode=fbml to work I finally figured it out!

In my IFRAM-application I navigate between pages by Response.Redirect("xxx.aspx?fbforcemode=fbml"); in the codebehind and the FBML just didn't want to show. But I use relative URLs and not absolute in my redirect! Once I changed the URLs to absolutes (ie. changed Response.Redirect("xxx.aspx?fbforcemode=fbml"); to Response.Write("<script>window.open(\"http://apps.facebook.com/myApp/xxx.aspx?fbforcemode=fbml\",\"_top\");</script>"); ) it started to work!

Hope this will help some who have the same problem as I did.
Jan 19, 2008 at 5:33 PM

noisinessism wrote:
After hours and hours of frustration without being able to get fbforcemode=fbml to work I finally figured it out!

In my IFRAM-application I navigate between pages by Response.Redirect("xxx.aspx?fbforcemode=fbml"); in the codebehind and the FBML just didn't want to show. But I use relative URLs and not absolute in my redirect! Once I changed the URLs to absolutes (ie. changed Response.Redirect("xxx.aspx?fbforcemode=fbml"); to Response.Write("<script>window.open(\"http://apps.facebook.com/myApp/xxx.aspx?fbforcemode=fbml\",\"_top\");</script>"); ) it started to work!

Hope this will help some who have the same problem as I did.


I try but the format of the redirect url make something like this http://www.mydomain.com/Default.aspxxxx.aspx?fbforcemode=fbml
how i redirect to http://www.mydomain.com/xxx.aspx?fbforcemode=fbml ?
Jan 20, 2008 at 1:26 PM


Ber79 wrote:I try but the format of the redirect url make something like this http://www.mydomain.com/Default.aspxxxx.aspx?fbforcemode=fbml
how i redirect to http://www.mydomain.com/xxx.aspx?fbforcemode=fbml ?

In the application settings, your 'Callback Url' must be http://www.mydomain.com/, not http://www.mydomain.com/Default.aspx
Does this solve the problem?
Jan 21, 2008 at 6:18 PM
Hi all,

I am using the following code in a .aspx page.

But, the fbml tags were not getting rendered.

Any help?

<fb:fbml>
<fb:share-button class="meta"> <meta name="medium" content="blog"/> <meta name="title" content="Leonidas in All of Us"/> <meta name="videotype" content="application/x-shockwave-flash"/> <meta name="videoheight" content="345"/> <meta name="videowidth" content="473"/> <meta name="description" content="That's the lesson 300 teaches us."/> <link rel="imagesrc" href="http://9.content.collegehumor.com/d1/ch6/f/6/collegehumor.b38e345f621621dfa9de5456094735a0.jpg"/> <link rel="videosrc" href="http://www.collegehumor.com/moogaloop/moogaloop.swf?clipid=1757757&autoplay=true"/> <link rel="target_url" href="http://www.collegehumor.com/video:1757757"/> </fb:share-button></fb:fbml>


Thanks in advance,
vara.
Jan 21, 2008 at 6:30 PM
Hi all,

Can't we use both the HTML and fbml tags together.

Are restricted to use only one?

I was comfortable in using the function setFBML(string) in writting some data on the user profile box.

But, the fbml tags were not getting rendered when they are used at the the html code side.

Can anyone expalin what is the problem here?

Thanks in advance,
vara.
Jan 28, 2008 at 8:15 PM
FINALLY GOT IT TO WORK!

This needs to be documented better.
to make the:

fbforcemode=fbml

to work,
you need to navigate to the FULL URL, not the relative URL of your site.

http://apps.facebook.com/myApp/xxx.aspx?fbforcemode=fbml


so you test, for yourself, on an aspx page that works in IFRAME,

<a href="http://apps.facebook.com/myApp//invite.aspx?fbforcemode=fbml" target="_top" >Invite Friends</a>


May 22, 2008 at 11:50 PM


mharper wrote:
I have successfully made an invitation page using the fbforcemode querystring. One thing that tripped me up is that you have to be testing on an externally facing machine. While iframes can load if the dns resolves on your local machine, fbml is loaded by the facebook servers, so has to be accessible to them.



This helped me fix my problem. Thanks. Just make sure to change the localhost to the corresponding domain in the app settings and be pointing at the FULL url, not pointing to localhost at all.
Mar 16, 2009 at 6:44 AM
I have to get extended permission which requires fbml tags.My app is in IFrame..The page where I ll be using fbml contains other javascripting and apis.
Is there any way except fb_forc_emode=fbm l?
Mar 22, 2010 at 3:37 PM
Edited Mar 22, 2010 at 3:38 PM

Hi all.

I have an I-frame based application and i want to create an "Invite friends" page.

Well,the link on that page is <a href="http://apps.facebook.com/APPNAME/INVITEFRIENDS.php?fbforcemode=fbml" target="_top">INVITEFRIENDS</a>

Than the fbml code of the form is:

<fb:fbml>
   <fb:request-form
     action="INVITEFRIENDS.php"
     method="POST"
     invite="true"
     type="War of kings"
     content="Messaggio da inviare agli amici <?php echo htmlentities("<fb:req-choice url=\"http://apps.facebook.com/APPNAME/\"
     label=\"Autorizza la mia applicazione\""); ?>"
    >
          <fb:multi-friend-selector
              showborder="true"
             actiontext="Invia i tuoi amici !"
          />
</fb:request-form>
</fb:fbml>

Is it right?

It doesn't works and i don't know why.

Can someone help me?