views:

59

answers:

1

I've been stuck on this for a while. I can't seem to get facebook login to pop up when following the google tutorial:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"&gt;&lt;/script&gt;
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"&gt;&lt;/script&gt;
<script>
    FB.init({appId:'137101656332358', status: true, cookie: true, xfbml: true});
    FB.Event.subscribe('auth.sessionChange', function(response) {
        if (response.session) {
            // A user has logged in, and a new cookie has been save
        } else {
            // The user has logged out, and the cookie has been cleared
        }
    });

I get the following error in Firebug:

Firebug cannot find _firebugConsole element true Window localhost:8000
Firebug cannot find _firebugConsole element true Window localhost:8000
Firebug cannot find _firebugConsole element true Window localhost:8000
FB is not defined
[Break on this error] FB.provide('',{getLoginStatus:function...ern:FB._inCanvas?0:2});return a;}}}); 

I set Site URL = http://localhost:8000/

thanks!

A: 

New Facebook API requires asynchronous load:

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    //[here goes your code:]
    FB.init({appId:'137101656332358', status: true, cookie: true, xfbml: true});
    FB.Event.subscribe('auth.sessionChange', function(response) {
        if (response.session) {
        // A user has logged in, and a new cookie has been save
        } else {
        // The user has logged out, and the cookie has been cleared
        }
    });
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());
</script> 
Tomasz Wysocki
thanks tomasz. how come they don't show this on the facebook developers page..is there any resource i can go to for this?thanks again.
David Hsu
Also, I just noticed..i still get some issues when i turn on firebug......with firebug on ..i cannot click the facebook connect button. any ideas?
David Hsu
http://developers.facebook.com/docs/reference/javascript/ - asynchronous thing
Tomasz Wysocki