Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Facebook's API is very tough to follow, and the documentation is very poor. You're right about the Javascript... normal Javascript only works inside an iframe on Facebook, otherwise you're limited to a subset of filtered Javascript called FBJS. You can safely ignore anything about FBJS in the documentation, and focus on iframes.</p> <p><strong>Iframe loading</strong></p> <p>The first thing I would mention is that an <code>&lt;fb:iframe&gt;</code> tag actually gets rendered with a ton of stuff in the <code>src</code> attribute. So if you put a tag like this into your Facebook page: <code>&lt;fb:iframe src="http://example.com/page?x=y"&gt;</code>, what it ends up becoming when it loads into a user's browser is more like this:</p> <p><code>&lt;iframe src="http://example.com/page?x=y&amp;fb_sig_in_iframe=1&amp;fb_sig_locale=en_US&amp;fb_sig_in_new_facebook=1&amp;fb_sig_time=1246340245.3338&amp;fb_sig_added=1&amp;fb_sig_profile_update_time=1242155811&amp;fb_sig_expires=1246345200&amp;fb_sig_user=000000001&amp;fb_sig_session_key=2.d13uVGvWVL4hVAXELgxkZw__.3600.1246345200-000000001&amp;fb_sig_ss=mZtFjaexyuyQdGnUz1zhYTA__&amp;fb_sig_api_key=46899e6f07cef023b7fda4fg2e21bc58&amp;fb_sig_app_id=22209322289&amp;fb_sig=bbc165ebc699b12345678960fd043033"&gt;</code></p> <p>Facebook adds a ton of stuff to the src. The parameter that tells you the user's Facebook id is <code>fb_sig_user</code> (which is 000000001 here). I'm assuming your app is set up as an "FBML app", since you probably wouldn't use an <code>&lt;fb:iframe&gt;</code> tag in an "Iframe app". Nonetheless, the rendering method is similar in both cases, and you get a bunch of extra stuff to your <code>src</code> document in an "Iframe app" as well.</p> <p>This really only passes you the Facebook user id on the first load of the iframe, however. Subsequent operations within the iframe won't have access to that user id unless you pass it around explicitly.</p> <p><strong>Facebook Connect</strong></p> <p>If you want to interact with Facebook from within the iframe, that's where the Facebook Connect Javascript libraries comes in. The best instructions on setting up Facebook Connect is probably <a href="http://wiki.developers.facebook.com/index.php/JavaScript_Client_Library#Setting_Up_the_JavaScript_Client" rel="nofollow noreferrer">this wiki page</a>, but it's still a bit murky. Facebook Connect can be used for both completely external sites, or just regular content inside an iframe. You fall into the latter category, so if you follow the instructions in that link and use the first line of code in step 2 (for the FeatureLoader), you should be ok.</p> <p>Once you've included the FeatureLoader.js script and called FB.init, you should generally be up and running with FB Connect. You should be able to interact with the <a href="http://wiki.developers.facebook.com/index.php/API" rel="nofollow noreferrer">API</a> from then on out. The <code>users.getLoggedInUser()</code> method will give you the current user id inside the iframe via Javascript.</p> <p>Hope that helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload