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ミドルウェアを使用しています)。