Facebook 应用程序选项卡 URL
我有一个 Facebook 应用程序,可以作为选项卡添加到粉丝页面。该应用程序要求用户经过身份验证才能使用它。这可以通过在链接中使用 requirelogin=1 来完成,该链接仅对未添加该应用程序的用户可见。这部分工作正常。
但是,在用户从 requirelogin 打开的 dhtml 弹出窗口授予我的应用程序权限后,我希望重新加载该选项卡。为了做到这一点,我需要将完整的 URL 包含在链接中,如下所示:
<a href="http://www.facebook.com/pages/PAGE_NAME/PAGE_ID?v=app_APP_ID" requirelogin=1>Authorize</a>
我不知道如何获取完整的 url,或者至少如何获取 PAGE_NAME 来动态构建此 url。似乎应用程序应该能够知道它在哪里,而无需任何特殊权限。
I have a facebook application that can be added to fan pages as a tab. The application requires that users are authenticated in order to use it. This can be accomplished by using requirelogin=1 in a link which is visible only to users who have NOT added the application. This part works fine.
However, after the user has given my application permission from the dhtml pop up that requirelogin opens, I want the tab to reload. In order to do that, I need the full URL to be included in the link as follows:
<a href="http://www.facebook.com/pages/PAGE_NAME/PAGE_ID?v=app_APP_ID" requirelogin=1>Authorize</a>
I cannot figure out how to get the full url or, at least, the PAGE_NAME to build this url dynamically. Seems like the app should be able to know where it is without any special permissions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当您的选项卡加载时,API 会向您传递一个签名请求,其中包含things,一个
page
数组包含id
、liked
和管理员
。您可以使用它来动态提取当前正在调用您的代码的页面 ID。When your Tab is loaded, the API passes you a Signed Request that contains, amongst other things, a
page
array containid
,liked
&admin
. You can use that to dynamically pull the page id that's currently calling your code.如果您有 PAGE ID 和 APP ID,则可以执行以下操作:
例如:
If you have the PAGE ID and APP ID, this is what you do:
For example:
在新方案中,# 不再起作用。需要使用 来
向应用程序携带参数,它必须在一个名为 'app_data' 的参数中。
要携带多个参数,最好的策略是将 app_data 编码为 Json。
In the new scheme, the # no long works. One needs to use
To carry parameters to the app, it has to be in a parameter called 'app_data'
To carry multiple parameters, the best strategy is to encode app_data in Json.
以上所有答案都不起作用(仅将您重定向到页面流)或现已弃用。最好的解决方案是使用 JS:
您还必须加载并初始化 facebook JS SDK。如果您不知道如何操作,请使用以下命令:
All of the above answers will not work (redirect you only to page stream) or are deprecated now. The best solution thou is using JS:
You'll also have to load and init facebook JS SDK. If you don't know how to do it, use this: