Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FB.getLoginStatus() called before calling FB.init(). How can I use Facebook API?

I use this code to prepare the usage of the FaceBook API:

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

However, on document load I get the error of:

FB.getLoginStatus() called before calling FB.init().

I don't understand this message. I've googled for this problem and found some forum threads, but unfortunately they were not helpful at all. I have decided to post a question here about this problem, as I am unable to resolve it, because I'm noob about Facebook API. Sorry if my question is too simple to anyone and thanks in advance for any answer.

like image 583
Lajos Arpad Avatar asked Dec 19 '12 14:12

Lajos Arpad


1 Answers

I have the same Facebook Log

 ***FB.getLoginStatus() called before calling FB.init().***

when document load. I find out that the #xfbml=1 in the end of

js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";

make this error. After deleting #xfbml=1, it's fine!

like image 99
capu Avatar answered Oct 06 '22 01:10

capu