-2

我可以登录,但我需要获取accessToken,以便可以调用其他 API,例如获取朋友等。

方法 ,getLoginStatus被调用但没有进入success响应块。

这是我的代码:

$(document).ready(function() {
    window.fbAsyncInit = function() {
        FB.init({
            appId: <<My appId>>, // App ID
            status: true, // check login status
            cookie: true, // enable cookies to allow the server to access the session
            xfbml: true,  // parse XFBML
            oauth: true
        });
        FB.getLoginStatus(function(response){
            alert('response='+response);
        });
        window.setTimeout(checkLogStatus, 1000);
        function checkLogStatus(){
            alert("check");
            // fetch the status on load
            FB.getLoginStatus(function(response){
                alert('response='+response);
            });
        }
    };

    // Load the SDK Asynchronously
    (function(d){
        var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement('script'); js.id = id; js.async = true;
        js.src = "//connect.facebook.net/en_US/all.js";
        ref.parentNode.insertBefore(js, ref);
    }(document));
});
4

1 回答 1

0

我需要获取 accessToken

SDK 通常能够很好地自行处理访问令牌——自动将其包含在对 API 的任何后续请求中,而无需您手动执行任何操作。

所以我不太清楚,你在这里实际遇到/试图解决什么问题。

于 2012-09-14T09:31:45.017 回答