invalid app Id: Must be a number or numeric string representing the application id. FB.getLoginStatus() called before calling FB.init().

this was my original code

(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id; js.async = true;
js.src = "//connect.facebook.net/{/literal}{$st_lb_locale}{literal}/all.js#xfbml=1;
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

I tried to add FB.init above it with app id but I get an error that FB.init was already called.

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

“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.”

So either use all.js or use the sdk.js

so change it to

(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id; js.async = true;
js.src = "//connect.facebook.net/{/literal}{$st_lb_locale}{literal}/all.js#xfbml=1&appId=<your app id>;
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

http://stackoverflow.com/questions/10415884/fb-init-has-already-been-called

Leave a Reply