我有一个页面正在运行,(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
views/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 上它不起作用。我得到一个空白屏幕。 但是,当我调用错误代码(例如:将访问 token 更改为错误的内容)时,我在 iframe 中得到了一个完整的 sinatra 错误页面...
有人知道我做错了什么吗?
谢谢!
最佳答案
Sinatra 试图避免点击劫持攻击。
添加这一行:
set :protection, :except => :frame_options
或这一行:
disable :protection
给你申请。
关于ruby - Facebook iframe 中的 Sinatra,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7847536/