Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FB.init has already been called

I am building facebook iframe app. My application is loaded once (I receive signed_request once) and then I navigate through the pages in the iframe using internal domain links. I noticed that I see these strange messages both in Chrome and Firefox

FB.init has already been called - this could indicate a problem 

I am pretty sure that this method is called only once and it seems Facebook wants me to call it once per application load (not once per page).

window.fbAsyncInit = function() {   FB.init({     appId: param('facebook_app_id'),     frictionlessRequests: true,     oauth: true,     channelUrl: site_url('/channel.html')   }) } 

What error (if any) am I making here?

like image 471
potomok Avatar asked May 02 '12 14:05

potomok


1 Answers

From the moment you pass parameters to the js.src like #xfbml=1&appId=X, FB SDK will auto init itself and thus FB.init will try to reinit.. So in your code, you don't have to remove the FB.init function, just make sure you don't pass parameters in the code that loads asynchronously the JS SDK.

Replace this:

js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=X"; 

With :

js.src = "//connect.facebook.net/en_US/sdk.js"; 

Hope this helps.

like image 151
Tinou Avatar answered Oct 13 '22 22:10

Tinou