SetFBML questions

Aug 14, 2008 at 8:15 AM
Hi there.

I don´t seem to be able to call SetFBML correctly. The method always returns true but there are no profile box in result of that.
Is there more to it that doing something like this:

var html = "<fb:narrow><div id='test'>TESTING THIS OUT</div></fb:narrow>";
var success = GetAPI().profile.setFBML(fs.uid, html, html, html);

I have set the app to narrow. Do I need to configure any additional settings in order to make it work?
Coordinator
Aug 19, 2008 at 3:42 AM
Are you testing this in the new profile or the old profile?
Aug 19, 2008 at 7:58 AM
I am testing with the new profile.
Aug 19, 2008 at 1:18 PM
I am getting an "facebook.Utility.FacebookException: Incorrect signature" error when  setting the  FBML.

Here is the code:

    Public fbService As facebook.Components.FacebookService = New facebook.Components.FacebookService()
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' ApplicationKey and Secret are acquired when you sign up for
        fbService.ApplicationKey = "xxxxxxxxxxxxxxxxxxxxxx"
        fbService.Secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        ' fbService.IsDesktopApplication = False

        Dim sessionKey As String = TryCast(Session("facebook_session_key"), String)
        Dim userId As String = TryCast(Session("facebook_userId"), String)

        ' When the user uses the facebook login page, the redirect back here will will have the auth_token in the query params
        Dim authToken As String = Request.QueryString("auth_token")

        If Not [String].IsNullOrEmpty(sessionKey) Then
            ' We have already established a session on behalf of this user
            fbService.SessionKey = sessionKey
            fbService.uid = userId
        ElseIf Not [String].IsNullOrEmpty(authToken) Then
            ' This will be executed when facebook login redirects to our page
            fbService.CreateSession(authToken)
            Session("facebook_session_key") = fbService.SessionKey
            Session("facebook_userId") = fbService.uid
            Session("facebook_session_expires") = fbService.SessionExpires
        Else
            ' Need to login
            Response.Redirect("http://www.facebook.com/login.php?api_key=" + fbService.ApplicationKey + "&v=1.0")
        End If

        fbService.profile.setFBML(fbService.uid, "testing the apps...", "testing the apps...", "")         
    End Sub


Aug 19, 2008 at 3:01 PM
Yes. The current source code is not working on most dev machines due to an invalid Facebook certificate.
Please refer to this post for details on how to fix this.

Hope it helps,
El
Aug 20, 2008 at 11:23 AM
Finally, I am able to run the follwing code without any error's.

My question is that the setFBML is running with no error's, but the box is not getting visible in the new profile "boxes" tab.

Here is the code:

    Private fbService As facebook.Components.FacebookService = New facebook.Components.FacebookService()
    ' Private fbService As facebook.Components.FacebookService = New facebook.Components.FacebookService()
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' ApplicationKey and Secret are acquired when you sign up for
        fbService.ApplicationKey = "xxxxxxxxxxxxxxxxxxxxxxxx"
        fbService.Secret = "xxxxxxxxxxxxxxxxxxxxxxxx"
        ' fbService.IsDesktopApplication = False

        Dim sessionKey As String = TryCast(Session("facebook_session_key"), String)
        Dim userId As String = TryCast(Session("facebook_userId"), String)

        ' When the user uses the facebook login page, the redirect back here will will have the auth_token in the query params
        Dim authToken As String = Request.QueryString("auth_token")

        If Not [String].IsNullOrEmpty(sessionKey) Then
            ' We have already established a session on behalf of this user
            fbService.SessionKey = sessionKey
            fbService.uid = userId
        ElseIf Not [String].IsNullOrEmpty(authToken) Then
            ' This will be executed when facebook login redirects to our page
            fbService.CreateSession(authToken)
            Session("facebook_session_key") = fbService.SessionKey
            Session("facebook_userId") = fbService.uid
            Session("facebook_session_expires") = fbService.SessionExpires
        Else
            ' Need to login
            Response.Redirect("http://www.facebook.com/login.php?api_key=" + fbService.ApplicationKey + "&v=1.0")
        End If
        fbService.profile.setFBML(fbService.uid, "I am testing the apps...", "I am testing the apps...", "")
    End Sub

Do I need to change any app setting's before I use the function setFBML() function?

Also, I have set Default Profile Box Column  to wide.

Am I missing something here...... Please help.






Aug 20, 2008 at 5:15 PM
I think the problem has been resolved now.

Actually, the profile box will not be visible when we set the FBML.

I have adjusted the setting's for the application by clicking on the pencil mark to display the profile box.




Aug 20, 2008 at 5:18 PM
Hi El,

I am still not able to import the following namespaces

Imports Facebook.WebControls
Imports Facebook.Entity

Could you share your Facebook related source code with me ?

I am using master page in my application, the samples provides a line like this:

FacebookAPI facebookAPI = ((CanvasIFrameMasterPage) Master).FacebookAPI;

I am getting an error if I use the same code.

Please help.


Aug 21, 2008 at 5:38 AM
The namespaces of the source project are lowercase...

....
using facebook.Forms;
using facebook.Properties;
using facebook.Schema;
using facebook.Utility;

namespace facebook
{
    /// <summary>
    /// Provides various methods to use the Facebook Platform API.
    /// </summary>
    public class API
    {
        internal const string ANDCLAUSE = " AND";
...

cheers,
El
Sep 2, 2008 at 8:58 AM
Edited Sep 2, 2008 at 8:59 AM
I'm using the following code and Facebook Developer Toolkit 1.7:


string fbml = "<fb:narrow>Hello World!</fb:narrow>";
string fbmlMobile = "<fb:mobile>This text appears only on m.facebook.com.</fb:mobile>";
FacebookAPI.SetFBML(fbml, "", fbmlMobile, FacebookAPI.UserId);

- SetFBML always returns 1, no matter what I try
- I'm able to add a box under Application Settings
- But "Boxes" within my profile is always empty and I cannot add any profile box belonging to my application

What am I doing wrong?
Sep 7, 2008 at 6:35 PM
I'm having similar troubles. I can set the FBML, and I can even get the Add Profile button to work and show the FBML output that I have set, but then no box ever appears, either in profile or in Boxes. 
Sep 8, 2008 at 8:33 AM
@ ibogost
Have you found a solution?
Sep 8, 2008 at 12:43 PM
No. I did find this, however, which suggests that it's a common issue: http://forum.developers.facebook.com/viewtopic.php?id=19975

I've tried modifying setFBML to use the new profile setting signatures, i.e. profile and profile_main, and as I said the FBML is getting set, because I see it in the add to profile preview. I just can't get the boxes to show up. 
Oct 17, 2008 at 5:20 AM
Edited Oct 17, 2008 at 5:21 AM
I too am in agreement that I cannot get setFBML to work to add content to a profile box.
As it stands, 2.0 toolkit does not seem to be handling this properly.
Are we all in agreement that this functionality does not work?
Is there anyone out there that can get setFBML to work with the 2.0 toolkit?

How many of us are still looking for answers here?
I think the list gets smaller every day.
I don't want to switch everything I've done over to Facebook.NET, but it seems to have more support...
Oct 17, 2008 at 9:54 AM
I have this in my Master Page...

this.API.profile.setFBML(this.API.uid, stringBuilder.ToString(), stringBuilder.ToString(), null);

My stringBuilder starts with "<fb:fbml version='1.1'>" and ends with "</fb:fbml>", everything else is good ol' HTML.  Works a treat.
Oct 17, 2008 at 3:17 PM
@mrated

After searching the whole net for this issue "add content to profile box" and trying all different dll's I finally found it. Biiiig thx to mrated. This tag <fb:fbml version='1.1'> solved my issue.
Oct 17, 2008 at 5:05 PM
Edited Oct 17, 2008 at 5:16 PM
Thanks!! I will give it a try and let you guys know...

(2 minutes later)

So, no result on my "boxes" tab.

I have a few questions about that.
1. Is there something I need to do to enable a box for my app on the edit settings page?
2. Is there a time lag between when I fire the setFBML and when is shows in the profile box, or should it be immediate?

For when I actually get it to work...
3. I am under the assumption that if I ever setFBML for a user, it overwrites the FBML I may have set previously for that user, is that how it works?


Oct 20, 2008 at 4:46 AM
I am bumping my previous questions in the hope someone out there can shed some light on them for me.
I am working on my app in my spare time, but I may actually be getting a paying client that wants a facebook app.
If I can't interact with the profile, I can't get the job.

(help)
Oct 20, 2008 at 7:44 AM
1. Is there something I need to do to enable a box for my app on the edit settings page?

You can have either in the Boxes tab or on the wall. To move the box click the "Edit" button (pencil). Then choose "move to wall" or "move to boxes tab" depending where your BOX is.


2. Is there a time lag between when I fire the setFBML and when is shows in the profile box, or should it be immediate?

I read that it can take a while before the box is updated. At least for me it updated immediately.


3. I am under the assumption that if I ever setFBML for a user, it overwrites the FBML I may have set previously for that user, is that how it works?

I'm not 100% sure if you understood you question correctly. But if you setFBML you always overwrite the content in the BOX.

Hope that helps.


Oct 20, 2008 at 3:55 PM
@Kostas

Thanks for your answers! 2 & 3 were exactly what I was looking for.
1 however I may not have explained well enough.

I don't see any markup related to my app on the boxes tab. I don't get a frame to be able to click on a pencil.
When I use Default FBML, I found that code (All I put in there was HELLO) on my app's about page.
I thought that the only piece I can't see in someone else's setup is their "Edit Settings" page.
As I look at Edit Settings, I don't really see any settings that would seem to make a difference.

When I use setFBML, it looks like what mrated suggested. When I see examples of "working" setFBML, the order of the parameters is different...