Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: FB.login() called before calling FB.init()

I use this Facebook Login Button code:

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
  FB.init({
    appId  : 'myActualId',
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true  // parse XFBML
  });
</script>
<fb:login-button show-faces="false" width="200" max-rows="1"></fb:login-button>

But the debug console gives me this error: FB.login() called before calling FB.init().

I made a test page so my error can be seen: http://www.comehike.com/test_fb_connect.php

I have no idea what I am doing wrong. Any help would be much appreciated!

Thanks, Alex

like image 347
Genadinik Avatar asked Feb 06 '11 01:02

Genadinik


3 Answers

If you pass the non existing FB app key to init() then only you get the error of 'FB.login() called before calling FB.init()'

Make sure, you hadn't been doing the same.

like image 119
Mohammad Arif Avatar answered Oct 26 '22 07:10

Mohammad Arif


You're loading the Facebook script all.js twice. It should be loaded only once.

like image 29
John Pick Avatar answered Oct 26 '22 08:10

John Pick


Seeing as no one on the interwebs was able to answer my question, I wiped out the old Facebook app entirely (on my developers.facebook.com account) and just made a new app from scratch and made a totally new one.

After that, the basic code did the job

like image 1
Genadinik Avatar answered Oct 26 '22 06:10

Genadinik