Facebook iframe 中的 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
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 上它不起作用。我得到一个空白屏幕。 但是,当我调用错误代码时(例如:将访问令牌更改为错误的内容),我会在 iframe 内看到完整的 sinatra 错误页面...
有人知道我做错了什么吗?
谢谢!
I have a page up and running, (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, the weird thing: In the browser it loads perfectly. However, on facebook it's not working. I get a blank screen.
However, when I invoke an error code (for example: changing the access token to something wrong), I get a full fledged sinatra error page inside the iframe...
Does anybody know what I'm doing wrong?
Thx!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Sinatra 试图避免点击劫持攻击。
将这一行:
或这一行:
添加到您的应用程序中。
Sinatra tries to avoid a click-jacking attack.
Add this line:
or this line:
to you application.