深入链接到Facebook画布应用 [英] Deep link into a Facebook canvas app

查看:133
本文介绍了深入链接到Facebook画布应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将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:

  1. 用户打开https://example.com/messages/123
  2. 应用程序检查 signed_request参数
  3. 应用程序将用户重定向到https://apps.facebook.com/EXAMPLE/?requested_page=/messages/123
  4. 应用程序检查requested_page参数并重定向到此页面
  5. 用户看到https://example.com/messages/123 URL,并嵌入到画布中
  1. User opens https://example.com/messages/123
  2. Application checks for signed_request parameter
  3. Application redirects user to https://apps.facebook.com/EXAMPLE/?requested_page=/messages/123
  4. Application checks for requested_page parameter and redirects to this page
  5. 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)

  1. 用户打开https://example.com/messages/123
  2. 应用程序在客户端检查应用程序是否嵌入在画布中:

  1. User opens https://example.com/messages/123
  2. 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屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆