FB.getLoginStatus一直返回连接

时间:2013-08-11 00:40:06

标签: node.js facebook facebook-graph-api facebook-javascript-sdk passport.js

尝试运行FQL查询并仅在用户登录时打印出结果(登录表单在同一页面上)。

相关代码 -

FB.init({
appId: '451320528308299',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml  : true, // parse XFBML
channelUrl: 'http://URL.COM/channel', // channel.html file
oauth  : true // enable OAuth 2.0
});

FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
    // the user is logged in and has authenticated your
    // app, and response.authResponse supplies
    // the user's ID, a valid access token, a signed
    // request, and the time the access token 
    // and signed request each expire
    FB.api({
        method: 'fql.multiquery',
        queries: {
            'query1': 'select status_id, message from status where uid = me()',
            'query2': 'select user_id, object_id from like where object_id in (#query1)'
        }
    },
    function(response){
        console.log(response);
    });
} else if (response.status === 'not_authorized') {
    // the user is logged in to Facebook, 
    // but has not authenticated your app
} else {
    // the user isn't logged in to Facebook.
}

上面的代码在$(document).ready中运行,即使没有登录,也会将输出打印到控制台。我做错了什么?

编辑 - 原来我已登录到Facebook.com(但已退出我的应用)。我正在调用req.logout()(使用ExpressJS的Passport中间件)。

0 个答案:

没有答案