深入链接到Facebook画布应用 [英] Deep link into a Facebook canvas app
问题描述
我正在将Facebook应用程序https://example.com
嵌入到Facebook应用程序画布中,以便可以在https://apps.facebook.com/EXAMPLE
上使用它.我的应用程序发送的通知电子邮件包含类似于https://example.com/messages/123
的链接,并且应该打开嵌入到Facebook画布中的页面.我该如何实现?我目前的想法:
I am embedding a Facebook app https://example.com
into the Facebook app canvas so that it is available at https://apps.facebook.com/EXAMPLE
. My application sends notification emails that contain links like https://example.com/messages/123
and that should open the page embedded into the Facebook canvas. How do I achieve this? My current thoughts:
- 用户打开
https://example.com/messages/123
- 应用程序检查
signed_request
参数 - 应用程序将用户重定向到
https://apps.facebook.com/EXAMPLE/?requested_page=/messages/123
- 应用程序检查
requested_page
参数并重定向到此页面 - 用户看到
https://example.com/messages/123
URL,并嵌入到画布中
- User opens
https://example.com/messages/123
- Application checks for
signed_request
parameter - Application redirects user to
https://apps.facebook.com/EXAMPLE/?requested_page=/messages/123
- Application checks for
requested_page
parameter and redirects to this page - User sees
https://example.com/messages/123
URL and is embedded into canvas
是否有更好的模式可以使它正常工作?
Is there a better pattern out there to get this working?
我的最终工作解决方案(使用Ruby on Rails)
- 用户打开
https://example.com/messages/123
-
应用程序在客户端检查应用程序是否嵌入在画布中:
- User opens
https://example.com/messages/123
Application checks on client-side if app is embedded in canvas:
if(window == top){
top.location = "https://apps.facebook.com/#{Settings.facebook.app_id}#{request.fullpath}";
}
用户被重定向到https://apps.facebook.com/EXAMPLE/messages/123
应用程序使用fb_graph gem解析signed_request
Application parses signed_request
with fb_graph gem
FbGraph::Auth.new(app_id, app_secret, :signed_request => params[:signed_request])
推荐答案
我只是将链接更新为从一开始就指向http://apps.facebook/example/messages/123
.
I'd just update the link to point to http://apps.facebook/example/messages/123
off the start.
在检查身份验证时,只需将授权/登录后的重定向设置为同一页面.
When you check for authentication just set the redirect after authorization/login to the same page.
无缘无故地在多个页面上重定向用户并不是一个好习惯.
Redirecting a user around multiple pages for no reason is just not a good practice.
这篇关于深入链接到Facebook画布应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!