0

我正在使用它通过我的应用程序向用户发送邀请给他的朋友,并在他们阅读我的应用程序上的新闻时请求公共操作的许可:

function xlfb_friendInvite() {
    FB.ui({method: 'apprequests',
        message: 'great app http://apps.facebook.com/xaluancom enjoin w me..',
    },
    function(receiverUserIds) {
        console.log("IDS : " + receiverUserIds.request_ids);
    });
    //http://developers.facebook.com/docs/reference/dialogs/requests/
}

但后来我发现该请求没有得到外部许可。当被邀请时,用户收到通知并接受了它,但没有权限,因此应用程序无法运行。

4

2 回答 2

0

When a user accepts a request that was sent to him, they are redirected to the canvas URL of your application. It is your application's responsibility to check and see if that user has authenticated your application and whether or not they have granted your application the correct permissions.

What you'll need to do is check to see if a user landing on your canvas URL is authenticated. Usually one would request permissions as part of the authentication process but this is not required.

You can test for permissions like this -

FB.api('/me/permissions', function (response) {
    console.log(response);
});

If the user has not granted all the required permissions then you can simply prompt them with the permissions dialog -

FB.ui({
    method: 'permissions.request',
    perms: 'user_likes',
    display: 'popup'
    },function(response) {
        if (response && response.perms) {
            alert('Permissions granted');
        } else if (!response.perms){
            alert('User did not authorize permission(s).');
        }
});

If you want to simply authenticate the user and request permissions as part of the login process then you can use some code similar to this -

FB.login(function(response) {
  // handle the response
}, {scope: 'email,user_likes'});
于 2012-05-26T08:49:24.747 回答
0

最后我找到了一个简单的解决方案。进入Settings > Auth Dialogue我的 Facebook 应用中心,然后点击“ edit these permissions”,然后输入“ public_stream, email”。

每次用户收到来自应用程序的邀请时,他们都会在授权应用程序时看到请求权限的窗口。

我还注意到该设置目前不支持“public_actions”。可能是 Facebook 团队忘记在此处设置选项。

无论如何,public_actions被 覆盖public_stream,所以我一点也不困惑。

感谢 Facebook 的 Open graph 团队。

于 2012-05-28T10:20:23.240 回答