Facebook iframe 中的 Sinatra

发布于 2024-12-11 10:18:30 字数 1385 浏览 0 评论 0原文

我有一个页面正在运行(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫腻 2024-12-18 10:18:30

Sinatra 试图避免点击劫持攻击。

将这一行:

set :protection, :except => :frame_options

或这一行:

disable :protection

添加到您的应用程序中。

Sinatra tries to avoid a click-jacking attack.

Add this line:

set :protection, :except => :frame_options

or this line:

disable :protection

to you application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文