Sinatra on Facebook iframe

I have a page up and down, (https://blooming-wind-8528.herokuapp.com/) using the following code:

App.rb contains:

require 'rubygems' require 'sinatra' require 'open-uri' require 'json' #show page get "/" do profile = open("https://graph.facebook.com/me?access_token=#full_access_code_here_removed_for_stackoverflow#").read profile = JSON.parse(profile) @language = profile['locale'][0..1] erb :nofan end #redirect for facebook post "/" do redirect "/" end 

views / nofan.erb contains:

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Stestie</title> <meta property="og:title" content="No Fan"/> <meta property="og:type" content="website"/> <meta property="og:url" content="https://blooming-wind-8528.herokuapp.com/"/> <meta property="og:image" content="https://blooming-wind-8528.herokuapp.com/images/marker_s.png"/> <meta property="og:site_name" content="NO fan"/> <meta property="fb:app_id" content="293597294002599" /> </head> <body> <p>App running in language: <%= @language %></p> </body> </html> 

Now, strange: in the browser it loads fine. However, this does not work on facebook. I get a blank screen. However, when I call the error code (for example: changing the access token for something is wrong), I get a full page with a sinatra error inside the iframe ...

Does anyone know what I'm doing wrong?

thanks!

+4
source share
1 answer

Sinatra tries to avoid a click attack.

Add this line:

 set :protection, :except => :frame_options 

or this line:

 disable :protection 

to your application.

+13
source

All Articles