Mau*_*oon 4 ruby iframe facebook sinatra
我使用以下代码启动并运行了一个页面(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
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
现在,奇怪的是:在浏览器中它完全加载.但是,在Facebook上它没有用.我得到一个空白的屏幕.但是,当我调用错误代码时(例如:将访问令牌更改为错误),我在iframe中获得了一个完整的sinatra错误页面...
有人知道我做错了什么吗?
谢谢!
Kon*_*ase 13
Sinatra试图避免点击攻击.
添加此行:
set :protection, :except => :frame_options
Run Code Online (Sandbox Code Playgroud)
或这一行:
disable :protection
Run Code Online (Sandbox Code Playgroud)
给你申请.
归档时间: |
|
查看次数: |
1688 次 |
最近记录: |