我有一个页面正在运行(https://blooming-wind-8528.herokuapp.com/),使用以下代码:
app.rb包含:
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
视图/nofan.erb包含:
<!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>
现在,奇怪的是:在浏览器中它加载得很好。不过,在facebook上,这是行不通的。我得到一个空白屏幕。
但是,当我调用错误代码(例如:将访问令牌更改为错误的内容)时,我在iframe中得到了一个完整的sinatra错误页……
有人知道我做错了什么吗?
谢谢!
最佳答案
辛纳特拉试图避免点击劫持攻击。
添加此行:
set :protection, :except => :frame_options
或者这句话:
disable :protection
给你申请。