I struggled for almost a day to get a skeleton iframe facebook app to render xfbml and wanted to spare others the gut wrenching experience.
URLs:
Canvas Callback URL :http://{app host}/
Connect URL :http://{app host}/
Canvas URL :http://apps.facebook.com/{app name}/
Setting the connect URL is very essential even though you are not developing a connect application per se. I guess facebook uses this to do cross domain requests.
Welcome page:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> <?php require_once 'facebook.php'; $appapikey = '<app key>'; $appsecret = '<secret key>'; $facebook = new Facebook($appapikey, $appsecret); $user_id = $facebook->require_login(); ?> <head> <title></title> </head> <body> This is the the the <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script> This is you: <fb:name uid="<?php echo $user_id?>"></fb:name> <script type="text/javascript"> FB.init("<app key>", "xd_receiver.htm"); </script> </body> </html>
Do not change the position of the JavaScript in the above code.
xd_receiver.htm:
<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>cross-domain receiver page</title> </head> <body> <script src="http://static.ak.facebook.com/js/api_lib/v0.4/XdCommReceiver.js?2" type="text/javascript"></script> </body> </html>
Facebook php client library can be downloaded from here.
Once rendered, you should see a link which takes you to your facebook home page.
Thanks a ton buddy. We were also stuck on the same issues for 2 days. This worked as a miracle. Thanks
That’s great, luckily I got stuck on this for 1 day before reaching this page which save the day š
well actually this works for <fb:name uid="”>
only, most of the other tags still not working, any idea?
http://wiki.developers.facebook.com/index.php/XFBML
I do not work actively on facebook apps. Whatever I have done is at a hobby level. But, I remember testing this with the photo tag. If you post which tag is not working maybe I can look into it.
Hi Abhirama,
Just wanted to say a big thank you for this post. I literally tried dozens of different configurations over the passed 2 days trying to get something working for a big deadline.
Your post is the first 100% working code example I have yet seen,
Paul
http://www.facebook.com/2008/fbml” no longer exists – so my site isn’t W3C conform – where can I find the new(est) fbml namespace`?
No ideas Doe. Maybe you can post in facebook api users forum.
In that respect, this item does function or at the very least does not make untrue claims.