【问题标题】:Facebook app with an iframe on rails带有 iframe on rails 的 Facebook 应用
【发布时间】:2009-06-08 16:14:58
【问题描述】:

我正在尝试创建一个 facebook 应用程序并浏览了 http://pragprog.com/titles/mmfacer/developing-facebook-platform-applications-with-rails 这本书。当我将画布渲染方法设置为 fbml 时,在我的开发机器上一切正常。但是,出于各种原因,我想用 iframe 构建一个应用程序。当我将我的应用程序设置为使用 iframe 时,我无法连接到我的开发机器。我浏览了很多关于创建 iframe 应用程序的不同文章,但似乎都没有。这包括

http://wiki.developers.facebook.com/index.php/Cross_Domain_Communication_Channel
http://wiki.developers.facebook.com/index.php/XFBML
以及任何其他网站在谷歌上搜索到 facebook、iframe、rails 和其他的任何组合。

我的公共目录中有 xd_receiver.htm 文件,我的布局看起来像

<!doctype html public “-//w3c//dtd xhtml 1.0 strict//en” “http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xmlns:fb=”http://www.facebook.com/2008/fbml”>
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  <title><%= controller.controller_name %>: <%= controller.action_name %></title>
  <%= stylesheet_link_tag "jquery-ui-1.7.1.custom.css", "styles" %>
  <%= javascript_include_tag "jquery-1.3.2.min.js", "application" %>
</head>
<body>

<%= yield  %>
<script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">  
    FB_RequireFeatures(["XFBML"], function(){ 
    FB.Facebook.init("my api key", "xd_receiver.htm"); });
</script>
</body>
</html>

我的问题是,当我将画布渲染方法设置为 iframe 时,我错过了什么阻止 facebook 连接到我的 Rails 开发机器?由于我的开发日志没有显示任何连接尝试,我猜测它与跨域的东西有关,但我无法在任何地方找到一个好的答案。

【问题讨论】:

    标签: ruby-on-rails ruby facebook iframe


    【解决方案1】:

    如果您将该文件放在 /public 下,请务必注意模板中包含的 ERB 不会像您预期的那样被解析。我对您尝试使用的插件不太熟悉,但使用了 Facebooker gem (http://facebooker.rubyforge.org/),它提供了一种与 Facebook REST API 交互的简洁方式。

    【讨论】:

    • (我会发表评论而不是答案,但我的分数不允许我)。
    【解决方案2】:

    我强烈建议从一开始就使用 Facebooker。 这将为您节省大量时间。

    【讨论】:

      【解决方案3】:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-07-13
        • 1970-01-01
        • 2011-12-21
        • 1970-01-01
        • 1970-01-01
        • 2011-07-26
        • 2015-01-24
        相关资源
        最近更新 更多