如何使用 Facebook.Rest.Api 检查配置文件 Id 是否具有权限并相应地重定向到授权页面?
对于给定的个人资料 ID,我需要从我的网站发布一条消息。我使用 Facebook.Rest.Api API 创建了一个 Facebook 应用程序。我发帖成功,但对于未授权的 ID,我想重定向到授权登录页面。
(window.top.location.href = "https://www.facebook.com/dialog/oauth?client_id=XXXXX&redirect_uri=http://XXXX.com&scope=publish_stream";)
我正在检查用户是否已使用 Facebook Connect 授予权限,然后使用上面的代码显示登录页面,以防个人资料 ID 仍不被允许。所以我期望登录页面,但它绕过了登录页面并显示重定向网址。
如果我单独尝试而不连接到 Facebook 来检查权限,它就可以正常工作。 有谁知道解决方案吗?
For a given profile ID, I need to post a message from my site. I created a facebook app using Facebook.Rest.Api
API. I was successful in posting but for IDs which are not authorised I want to redirect to the authorise login page.
(window.top.location.href = "https://www.facebook.com/dialog/oauth?client_id=XXXXX&redirect_uri=http://XXXX.com&scope=publish_stream";)
I am checking whether the user already gave permission using Facebook Connect, and then using above code to show login page in case the profile ID is not still permitted. So I expect login page, but instead it bypasses that and shows the redirect url.
If I try separately without connecting to facebook for checking permission it works fine.
Does anyone know of a solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,SDK/Facebook 知道何时通过您传递到 Perms 设置的内容来请求用户允许执行某些操作。
如果您需要发布到那里的提要,请将权限“publish_stream”添加到 CanvasAuthorizer,如下所示。
然后只需检查用户是否授权该访问即可。
So the SDK/Facebook knows when to ask the user for permision to do something by what you pass into the Perms setting.
If you need to post to there feed add the permission "publish_stream" to the CanvasAuthorizer like this.
Then is is just a matter of checking if the user authorized that access.