Facebook graph api 当用户到达我已经登录的facebook应用时,如何检测已取消的权限请求?
我一直在测试javascript sdk的身份验证/登录代码,我注意到facebook只在用户到达我的未登录facebook的应用程序时检测到已取消的权限请求,但如果用户已经登录facebook,并且他们取消了相同的权限请求,FB.login不会返回“未知”在第一个条件下的状态Facebook graph api 当用户到达我已经登录的facebook应用时,如何检测已取消的权限请求?,facebook-graph-api,facebook-javascript-sdk,Facebook Graph Api,Facebook Javascript Sdk,我一直在测试javascript sdk的身份验证/登录代码,我注意到facebook只在用户到达我的未登录facebook的应用程序时检测到已取消的权限请求,但如果用户已经登录facebook,并且他们取消了相同的权限请求,FB.login不会返回“未知”在第一个条件下的状态 $("button").click(function(){ FB.login(function(response) { /*when the user clicks t
$("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'});
});
当我尝试测试验证响应时,我发现自己忽略了什么,如果我到达我的应用程序并已登录,然后取消了授权,那么我将得到验证响应。我需要确保我还没有授权这个应用!!!是吗?!!不管是谁,我需要从我的fb主页上的person应用列表中删除该应用,然后我就可以进入我的登录页,就好像我是一个新用户一样
FB.login(function(response) {
console.log(response);
if(response.status === "connected"){
//here I have ajax method for passing the signed request to my php page
}else if(response.status === "not_authorized"){
//if they arrive logged in, are prompted to accept permissions, then cancel
//permissions request
console.log("authCancelled");
}
else{
//if user arrives at app not logged in they'll be prompted to log in,
// if they log in and then cancel the permissions request, I'll get an auth response of "unknown"
//and then I redirect the page.
top.location.href = "my redirect url";
}
},{scope: 'user_location,user_likes'});
});
如果您想验证您是否被授予了所有需要的权限,那么您可以进行类似于
FB.api('/me/permissions',function(perms){…})的api调用代码>