如何为通过粉丝页面选项卡访问的 Facebook 应用程序显示 OAuth 对话框?

发布于 2024-12-17 03:03:44 字数 297 浏览 4 评论 0原文

我正在开发一个 Facebook 应用程序作为页面选项卡应用程序。我想在用户通过粉丝页面访问应用程序之前显示 OAuth 对话框。我该怎么做?

对于画布应用程序,当我从应用程序设置(增强型身份验证对话框)启用 OAuth 对话框时,通过 apps.facebook.com/myapp 访问应用程序时会显示 OAuth 对话框。我使用添加在粉丝页面内的页面选项卡访问同一应用程序,但未显示 OAuth 对话框。

I'm developing a Facebook application as a Page Tab App. I want to show the OAuth dialog box before the user access the application via the fan page. How can I do this?

For a canvas app, when I enable the OAuth dialog box from the application settings (Enhanced Auth Dialog) the OAuth dialog box is shown when the application is accessed via apps.facebook.com/myapp.But when I access the same application using the page tab added inside a fan page, the OAuth dialog is not shown.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执笔绘流年 2024-12-24 03:03:44

请参阅教程Canvas 教程

关键技巧是您需要定位“_top”窗口(iframe 外部)...例如,

echo('<script> top.location.href="' . $auth_url . '"</script>');

或者

echo('<a target="_top" href="' . $auth_url . '">Authorize this application...</a>');

据我所知,您无法在 iframe 内部完成此授权流程。

我还建议观看来自 Facebook 的短视频身份验证:概述开发商车库:巴黎(2011-03-29)。

如果您想请求身份验证(或在身份验证后添加一些额外的权限),请参阅两个 JavaScript SDK 函数,FB.getLoginStatusFB.login。请注意,FB.login 会启动一个弹出窗口 - 因此它必须由用户click 事件触发(否则某些浏览器会阻止弹出窗口)。此方法的好处是它不需要页面重定向 - 弹出窗口会传回响应而无需重新加载。

See the tutorial Canvas Tutorial.

The key trick is that you need to target the "_top" window (outside of the iframe)... For example,

echo('<script> top.location.href="' . $auth_url . '"</script>');

or

echo('<a target="_top" href="' . $auth_url . '">Authorize this application...</a>');

To my knowledge you can not complete this authorization flow inside of the iframe.

I also recommend watching the short video Authentication: An Overview from Facebook Developer Garage: Paris (2011-03-29).

If you want to request authentication (or add on some additional permissions after authentication) see the two JavaScript SDK functions, FB.getLoginStatus and FB.login. Take note that FB.login launches a popup window - so it must be triggered from a user click event (or some browsers will block the popup). The benefit of this method is it doesn't require page redirects - the popup communicates back the response without a reload.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文