我正在使用此功能通过我的应用向用户发送邀请,并在我的应用上阅读新闻时要求获得公开操作的许可:
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/
}
但后来我发现该请求未获得外部许可。受邀时,用户收到通知并接受通知,但没有权限,因此应用程序无法正常工作。
答案 0 :(得分:0)
当用户接受发送给他的请求时,会将其重定向到应用程序的画布URL。您的应用程序负责检查该用户是否已对您的应用程序进行了身份验证,以及他们是否已授予您的应用程序正确的权限。
您需要做的是检查登录画布网址的用户是否经过身份验证。通常,人们会在身份验证过程中请求权限,但这不是必需的。
您可以测试这样的权限 -
FB.api('/me/permissions', function (response) {
console.log(response);
});
如果用户未授予所有必需的权限,则只需使用权限对话框提示 -
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).');
}
});
如果您只想在登录过程中对用户进行身份验证并请求权限,那么您可以使用与此类似的代码 -
FB.login(function(response) {
// handle the response
}, {scope: 'email,user_likes'});
答案 1 :(得分:0)
最后我发现了一个简单的解决方案。转到我的FaceBook应用中心的Settings > Auth Dialogue
,然后点击“edit these permissions
”,然后输入“public_stream, email
”。
每次用户收到应用邀请时,他们都会在授权申请时看到要求许可的窗口。
我还注意到该设置目前不支持“public_actions”。可能是Facebook团队忘记在那里提供选项。
无论如何,public_actions
涵盖public_stream
,所以我根本不会感到困惑。
感谢FaceBook的Open图形团队。