Anyone have a fix for the new setFBML change?

Jan 2, 2008 at 10:10 AM
As this api method is changing as told here - http://developers.facebook.com/news.php?blog=1&story=61

I was wondering if any one has got a fix for this already so theres plenty of time to get apps tested and working with the new method - Just in case the fix gets released on here a little too late.

Thanks
Jan 3, 2008 at 8:27 AM
Never mind - i have a fix here that i implemented last night and it seams to work fine. For those of you interested:

Add this method to FacebookAPI.cs

public string SetFBML(string markup, string userId, string profileMarkup, string actionsMarkup, string mobileMarkup)
{
string results = string.Empty;
Dictionary<string, string> parameterList = new Dictionary<string, string>();

parameterList.Add("method", "facebook.profile.setFBML");

parameterList.Add("markup", string.Format(CultureInfo.InstalledUICulture, markup));
if (!string.IsNullOrEmpty(userId))
{
parameterList.Add("uid", string.Format(CultureInfo.InstalledUICulture, userId));
}
parameterList.Add("profile", string.Format(CultureInfo.InstalledUICulture, profileMarkup));
parameterList.Add("profile_action", string.Format(CultureInfo.InstalledUICulture, actionsMarkup));
parameterList.Add("mobile_profile", string.Format(CultureInfo.InstalledUICulture, mobileMarkup));

string xml = ExecuteApiCallString(parameterList, true);

if(!string.IsNullOrEmpty(xml))
{
XmlDocument xmlDocument = LoadXMLDocument(xml);

XmlNodeList nodeList = xmlDocument.GetElementsByTagName("profilesetFBMLresponse");

if(nodeList != null && nodeList.Count > 0)
{
if(nodeList0.HasChildNodes)
{
results = nodeList0.InnerText;
}
}
}

return results;
}

And add this method to FacebookService.cs

public string SetFBML(string markup, string userId, string profileFBML, string actionFBML, string mobileFBML)
{
string results = string.Empty;

if(!IsSessionActive() && IsDesktopApplication)
{
ConnectToFacebook();
}
try
{
results = _facebookAPI.SetFBML(markup, userId, profileFBML, actionFBML, mobileFBML);
}
catch(FacebookTimeoutException)
{
_facebookAPI.SessionKey = null;

if(IsDesktopApplication)
{
ConnectToFacebook();
SetFBML(markup, userId, profileFBML, actionFBML, mobileFBML);
}
else
{
throw;
}
}

return results;
}

Then if you just want to set normal fbml as before call: SetFBML("", userId, fbml, "", "");
Sep 3, 2008 at 10:36 AM
Is '1' the corret return value?