Talk:Profile.setFBML
From Facebook Developer Wiki
[edit] Feature Requests
[edit] Refresh multiple refs
[edit] Remove profile box from profile
[edit] profile_action parameters
Why are you not using associative arrays for these params? This way, you never have to deprecate parameter lists:
$data = array("mobile" => "....", "profile" => "....");
$facebook->api_client->profile_setFBML($data);
Just my 2 cents.
[edit] Please Please Please
Do not make this change until sometime in January. Many people including myself will be unable to change our code.
- The change has been postponed to January 2008, according to the updated blog post. 506843584 22:01, 17 December 2007 (PST)
[edit] Also see FBML fb:ref
Astonishing this page doesn't contain a pointer to fb:ref and the API setRefHandle(). Be sure to look at that material.
[edit] Questions and Issues
[edit] "Add to Profile" Button Displays but "No content to display" Message Is Given.
Although the Profile.setFBML seems to work because the "Add to Profile" Button displays. The AJAX pop-up preview of what it will look like in the profile displays:
"<APP NAME> No content to display. This box will not be visible to people who view your profile until this application adds content to it."
Although this might make sense if there was no FBML to display, there is. If it is added to the Boxes Tab (Even though the preview still gives the message above), the FBML renders properly in the user's Boxes tab. However, if it is put on the Wall and Info Tab, it renders the message shown in the preview.
Solution
This turns out to be a bug in 'profile_setFBML'
The solution is listed on the developer forum
Pasted below for reference:
Define $ProfileContent and $ProfileContent2 as necessary, using strings or FBML.
$facebook->api_client->call_method('facebook.Fbml.setRefHandle',
array(
'handle' => 'bla_w',
'fbml' => $ProfileContent, // wide box
) );
$facebook->api_client->call_method('facebook.Fbml.setRefHandle',
array(
'handle' => 'bla_n',
'fbml' => $ProfileContent2, // narrow box and main box
) );
$facebook->api_client->call_method('facebook.profile.setFBML',
array(
'uid' => $user,
'profile' => '<fb:wide><fb:ref handle="bla_w" /></fb:wide><fb:narrow><fb:ref handle="bla_n" /></fb:narrow>',
'profile_main' => '<fb:ref handle="bla_n" />'
)
);
[edit] Is there a limit as to how many characters the markup can contain?
I am finding it is getting cut off if it is too long.
- Currently it's 64k (with a couple of header bytes off) after gzip level 6 compression. So, it's hard to tell exactly how many bytes you can have prior to compression. If you can control it within 64k (minus a couple of bytes), you will be guaranteed not to have any truncations, although when size is around 64k, we normally see compression rate about 8-10x. Per this discussion thread: http://www.facebook.com/topic.php?uid=2205007948&topic=11761 - Haiping Zhao, hzhao at facebook d o t com
[edit] Syntax
<?php //i.e. $user can come from $user = $facebook->require_login(); $html = "<fb:profile-action url='http://apps.facebook.com/myapp/somepage.php'> Hello World </fb:profile-action>"; $html .= "<fb:wide> Be careful with this. It seems to cache and stuff. Does not append, but replaces. PITA </fb:wide>"; $html .= "<fb:narrow> This only shows if panel is on the left. Dear user. Please move this to the wide panel instead. Blah. </fb:narrow>"; $facebook->api_client->profile_setFBML($html, $user); ?>
[edit] profile_action parameter not working yet?
Does setting the profile action FBML work for anyone yet using the profile_action parameter? I've not had any luck w/ this yet...
- Having the same issue here. -216900466 02:25, 17 December 2007 (PST)
Can we have a clear set of examples on the use of this function, i.e. new and old syntax. I and many others may be unsure of exactly what changes we need to make. Also, the main article for this function only gives an xml return example, the list or required parameters is useless without the syntax on how to use them... for a beginner.
[edit] Error response Code 1?
If this call returns 1 it's not an error - it's successful?
Yes, as any other function on any programming language (PHP, Java, C) --alvin 07:35, 5 October 2008 (PDT)
[edit] Example request profile_setFBML() is invalid PHP code
You can't have an empty first parameter:
$facebook->api_client->profile_setFBML('profile fbml here', 12800193, 'profile FBML here', 'profile action fbml here', 'mobile fbml here');
Instead I pass null or the same data as the profile parameter but the past couple of days my apps have been plagued by intermittent timeouts.
Looking at the PHP library I see profile_setFBML($markup, $uid = null, $profile=, $profile_action=, $mobile_profile=) i.e. the markup is first, followed by an optional uid...
[edit] PHP 5 Example
Not sure where this would go but here it goes.
If you want to run $facebook->api_client->profile_setFBML(, 12800193, 'profile FBML here', 'profile action fbml here', 'mobile fbml here'); successfully in PHP5
encase it in a try catch.
try{
$facebook->api_client->profile_setFBML(, 12800193, 'profile FBML here', 'profile action fbml here', 'mobile fbml here');
}catch(FacebookRestClientException $e){
echo $e->getMessage();
}
otherwise it will kill your script. might be a no brainer but thought I would point it out.
[edit] Error Code Discussion
[edit] Error 100
Note: Error 100 will be returned if the UID you're sending to has been deactivated.
^Well that absolutely sucks. Is there anyway to suppress this error? This makes batching using profile.setFBML absolutely fruitless because the entire batch is not executed if there's at least one call to profile.setFBML that returns '100 Invalid parameter'. I'm not gonna go through hundreds of thousands of users and check if they're still active every time I need to update their profiles.
[edit] How to update profiles of all users who installed your app?
How to update profiles of all users who installed your app. As I can't get list of their ids, is there a way?
-You have to store FB ids mapped to local ids and then have users grant offline access. Then you can run scripts to do such a thing.
[edit] profile_setFbml giving timeout
I have been using profile_setFbml function perfectly using new facebook libraries, but from yesterday onwards it started giving me timeout problem. Is there any way to figure out the reason of this or this is a bug altogether in the new profile_setFbml function.
[edit] docs?
someone help me understand why the example is actually the correct syntax, but the whole article above it, with the required parameters and what not, is not correct.
[edit] Do it this way, it works
I'm a pretty seasoned programmer, have dealt with more APIs and such than I can remember. Simply calling setFBML with the required params, as indicated by the docs, the books, etc. just plain doesn't work; the syntax is simple, I have tried every example I can find, there has to be something that isn't being revealed. Using the examples, you get the correct preview when the user clicks "add to profile", but the content doesn't show up in the profile box.
This piece of code appears to be a way that works, every time.
$facebook->api_client->call_method('facebook.profile.setFBML', array ( 'uid' => $user, 'profile' => '<fb:wide><fb:ref handle="widecontentHandle" /></fb:wide><fb:narrow><fb:ref handle="narrowcontentHandle" /></fb:narrow>', 'profile_main' => '<fb:ref handle="narrowcontentHandle" />' ) );
Notice the fb:ref tags, which accesses FBML via referencing the "handle" that you have already defined previously (handle means reference), which according to the docs ""references a cached handle stored on the facebook servers this is set via the fbml.setRefHandle API method" and fills it into the narrow and wide tags. Look up the fb:ref tag and API calls (it's a very, very handy one, any FB developer should know it).
What do I suspect? Not sure: three things:
- The data, as set by the method indicated in the standard docs, doesn't make the data available to the profile box.
- The simple API call itself is either wonky, or there is some dependent function or setting you must call or be aware of outside of the simple usage.
- The function usage is just improperly documented (all those deprecated args, etc.).
Either way, the standard one doesn't work for me, this one does.
- Thanks for posting this. I was speaking with one of our Platform engineers who confirmed that the sample code in the article is correct. He did say that your example works great, too, and is not sure why you're having issues. Tho he thinks yours works because you use call_method (which I'll try to document soon). The fb:ref stuff is just an elegant way to reference your FBML. Which leads us to two possibilities:
- The client library used by people who are experiencing problems could be out of date. The latest is at http://svn.facebook.com/svnroot/platform/clients/php/trunk/
- There could be something going on in our code. In this case, please file a bug and reference the error messages or results you're (not) seeing.
- Thanks for helping out here, tho. -- Pete (563683308 17:22, 20 November 2008 (PST))
Contact tcoz@tcoz.com if you have questions.
This works great (and the only solution that works for Wall Profile Box), thanks for the tip!
-- another FB Application Developer
It works fo me too, I lost about an hour trying to solve the problem and guess what? the docs are WRONG.
