Note that there are some explanatory texts on larger screens.

plurals
  1. PODeep link into a Facebook canvas app
    primarykey
    data
    text
    <p>I am embedding a Facebook app <code>https://example.com</code> into the Facebook app canvas so that it is available at <code>https://apps.facebook.com/EXAMPLE</code> . My application sends notification emails that contain links like <code>https://example.com/messages/123</code> and that should open the page embedded into the Facebook canvas. How do I achieve this? My current thoughts:</p> <ol> <li>User opens <code>https://example.com/messages/123</code></li> <li>Application checks for <a href="https://developers.facebook.com/docs/authentication/signed_request/" rel="nofollow"><code>signed_request</code> parameter</a></li> <li>Application redirects user to <code>https://apps.facebook.com/EXAMPLE/?requested_page=/messages/123</code></li> <li>Application checks for <code>requested_page</code> parameter and redirects to this page</li> <li>User sees <code>https://example.com/messages/123</code> URL and is embedded into canvas</li> </ol> <p>Is there a better pattern out there to get this working?</p> <p><strong>My final working solution (with Ruby on Rails)</strong></p> <ol> <li>User opens <code>https://example.com/messages/123</code></li> <li><p>Application checks on client-side if app is embedded in canvas:</p> <pre><code>if(window == top){ top.location = "https://apps.facebook.com/#{Settings.facebook.app_id}#{request.fullpath}"; } </code></pre></li> <li><p>User is redirected to <code>https://apps.facebook.com/EXAMPLE/messages/123</code></p></li> <li>Application middleware converts <code>POST</code> into <code>GET</code> if <code>signed_request</code> is present (code and idea borrowed from <a href="https://github.com/dekart/facebooker2/blob/master/lib/facebooker2/rack/post_canvas.rb" rel="nofollow">https://github.com/dekart/facebooker2/blob/master/lib/facebooker2/rack/post_canvas.rb</a>)</li> <li><p>Application parses <code>signed_request</code> with fb_graph gem</p> <pre><code>FbGraph::Auth.new(app_id, app_secret, :signed_request =&gt; params[:signed_request]) </code></pre></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload