我一直在测试 javascript sdk 的身份验证/登录代码,我注意到 facebook 仅在用户到达我的应用程序但未登录 facebook 时检测到取消的权限请求,但如果用户已经登录到 facebook 和他们取消了相同的权限请求,FB.login 不会像在第一个条件下那样返回“未知”状态。
$("button").click(function(){
FB.login(function(response) {
/*when the user clicks the button but isn't logged in, fb will prompt
them to log in and then shows the dialogue where I request
permissions. If I hit cancel, the response status will return
"unknown" and I redirect to another page. */
if(response.status === "unknown"){
top.location.href = "https://developers.facebook.com/docs/facebook-login/access-tokens/";
}else{
/*However if the user is already logged in and the permissions
request is cancelled, the code goes into this block that is meant to
handle a "connected" response */
console.log("connected");
},{scope: 'user_location,user_likes'});
});