我正在尝试找到用户从我的应用程序注销时的情况解决方案,但仍然在Facebook上登录,并尝试通过OAuth再次登录我的应用程序。
我正在通过收听'auth.login'事件检查授权状态
当用户在这种情况下单击facebook-connect按钮时,弹出窗口会自动关闭,然后没有任何反应(因为用户已登录facebook,登录事件未被触发)。如果我添加getLoginStatus()检查,那么用户在打开页面时会自动登录到我的应用程序,即使他没有点击facebook-connect按钮(这就是我不想要的)任何想法?谢谢!
答案 0 :(得分:1)
当用户已登录此FB事件时,请在此处指定执行代码。
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
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
} 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.
}
});