0

如果我有一个用户已经登录到 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' });
            };
        });
    }  
4

1 回答 1

0

似乎我误解了您的问题,并且您希望用户保持登录状态,即使他从 Facebook 上的帐户中删除了应用程序。这真的很糟糕,很容易成为安全问题。

一旦用户删除了您的应用程序,他就不应该登录!

如果您不想在用户下次访问您的应用程序之前提示用户权限,您应该定义您的情况下的“下一次”(小时/天/浏览器会话/等)并设置一些 cookie/会话检查每次访问是否是正确的提示时间。


您可以使用第二个参数FB.getLoginStatus来始终获取用户的最新状态(对于删除您的应用程序的用户不会返回connected)。

FB.getLoginStatus(function(response) {
  // this will be called when the roundtrip to Facebook has completed
}, true);

请参阅文档的“往返 Facebook 的服务器”部分FB.getLoginStatus

于 2012-09-23T11:52:49.747 回答