0
如果我有一位已經登錄Facebook的用戶,但是從他/她的帳戶中刪除了我的應用,那麼只有在再次輸入我的應用時才提示輸入publish_stream,因爲用戶已經登錄?Facebook +僅提供發佈流
謝謝。
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
uid = response.authResponse.userID;
accesstoken = response.authResponse.accessToken;
SrReferral = '@ViewBag.Referral';
window.fbuserid = uid;
var postData = { facebookUID: uid, facebookAccessTok: accesstoken, facebookSrReferral: SrReferral };
$.ajax({
url: '@Url.Action("DisplayGolfers")',
type: 'POST',
data: postData,
dataType: 'html',
success: function (responseText) {
$("#container").html(responseText);
}
});
} 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.
window.FB.login(function (response) {
if (response.authResponse) {
uid = response.authResponse.userID;
accesstoken = response.authResponse.accessToken;
SrReferral = '@ViewBag.Referral';
window.fbuserid = uid;
var postData = { facebookUID: uid, facebookAccessTok: accesstoken, facebookSrReferral: SrReferral };
$.ajax({
url: '@Url.Action("DisplayGolfers")',
type: 'POST',
data: postData,
dataType: 'html',
success: function (responseText) {
$("#container").html(responseText);
}
});
} else {
console.log('User cancelled login or did not fully authorize.');
alert('User cancelled login');
}
}, { scope: 'publish_stream' });
};
});
}
謝謝,我讀從http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus文檔/其中一個狀態是用戶登錄到FB但尚未驗證我的應用程序,我認爲其中一種情況可能是用戶登錄,驗證我的應用程序,但是從他的帳戶設置之後立即刪除它,因此存在'else if(response.status ==='not_authorized')'。我不確定爲什麼用戶在刪除我的應用程序時不應該登錄?如果我錯了,請糾正我。謝謝。 – k80sg
@ user415795,好吧,一旦用戶移除你的應用程序,他在技術上仍然是登錄的,但是一旦你知道他不再是你的應用程序的用戶,它應該被註銷(或者提供回去的可能性) 。使用'FB.getLoginStatus'和第二個參數等於'true'將確保從Facebook獲取新的狀態,並且您將注意到用戶沒有登錄到您的應用程序。如果你調用沒有第二個參數的'FB.getLoginStatus',你將得到'authResponse'緩存,這可能不代表與用戶連接的真實狀態。 –