Facebook соединяется с Django / Python - PullRequest
2 голосов
/ 28 августа 2010

Я застрял на этом некоторое время.Я не могу получить логин на Facebook, чтобы всплывающее окно после урока Google:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<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
        }
    });

В 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;}}}); 

Я установил Site URL = http://localhost:8000/

спасибо!

1 Ответ

1 голос
/ 28 августа 2010

Новый API Facebook требует асинхронной загрузки:

<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> 
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...