2

I have Facebook Authentication setup on my application using the Facebook Javascript SDK. I currently don't ask for the email permission. I want to prompt users for email permission but only for users who have not given basic permissions to my site already.

Is there a way to prompt email permission only if they have not given basic permissions to my application?

If possible, I'd like to be able to do this without multiple permissions popups.

4

1 回答 1

1

看看我的理解是否正确,你的意思是对于目前没有你的应用程序授权的用户,当你要求他们登录时,你想请求他们的电子邮件许可,而对于你授权的用户,没有改变,对吧?

如果是这样,这样的事情就可以解决问题,在您的 FB.init 之后或单击按钮或您现在正在进行 FB 登录的任何地方插入它:

FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
        // log the user into your site using FB.getAccessToken() or do whatever you normally do.
    } 
    else if (response.status === 'not_authorized') {
        // ask the user for permissions
        FB.login(function(response) {
            // handle response
        }, {scope: 'email'});
    }
});

警告:如果用户当前未登录 Facebook 并且您的应用程序已获得授权,这将无济于事,要使其不这样做,您必须将 else if 替换为一般的 else,但它会在老用户登录时显示“请求电子邮件权限”弹出窗口。

于 2012-08-02T22:23:05.943 回答