1

我们编写了一个代码来使用 FaceBook Connect API。单击 facebook 按钮,登录窗口打开,我输入了我的 facebook 凭据并登录到 facebook,但是我应该通过它从 facebook 获得响应的回调函数没有被调用。任何人都可以让我知道我哪里出错了。

<script type="text/javascript">
    $("document").ready(function () {
        // Initialize the SDK upon load
        FB.init({
            appId: 'My APP ID', // App ID
            scope: 'id,name,gender,user_birthday,email', 
            status: true, // check login status
            cookie: true, // enable cookies to allow the server to access the session
            xfbml: true  // parse XFBML
        });
        // listen for and handle auth.statusChange events
        //FB.Event.subscribe('auth.login', OnLogin);
    FB.Event.subscribe('auth.login', function(response) {
      alert('The status of the session is: ' + response.status);
    });
    });

    // This method will be called after the user login into facebook.
    function OnLogin(response) {
        if (response.authResponse) {
            FB.api('/me?fields=id,name,gender,email,birthday', LoadValues);               


        }
    }

    //This method will load the values to the labels
    function LoadValues (me) {
        if (me.name) {
           alert(me.name);
        }
    }
</script>
4

0 回答 0