没有PHP的iframe应用程序(请使用Rails或javascript)的FacebookLeaverTab/LikeGate

没有PHP的iframe应用程序(请使用Rails或javascript)的FacebookLeaverTab/LikeGate,javascript,ruby-on-rails,ruby-on-rails-3,facebook,iframe,Javascript,Ruby On Rails,Ruby On Rails 3,Facebook,Iframe,所以我在facebook上有一个页面,通过我制作的应用程序有一些标签。它们是促销标签。对于其中的一些标签,我想显示备用的摘要内容,直到他们“喜欢”了页面。我不使用PHP,所以请只使用JS或Ruby 我不需要做任何fb connect的事情,也不需要知道他们是否喜欢我网站上的应用程序/页面。。。我所需要的一切都将通过iframe在facebook上进行 谢谢 [编辑:查看redbull的粉丝页面:这就是我想要做的]得到了一个没有PHP的工作解决方案。感谢小矮人的启发 这不是一个JS解决方案,我不认

所以我在facebook上有一个页面,通过我制作的应用程序有一些标签。它们是促销标签。对于其中的一些标签,我想显示备用的摘要内容,直到他们“喜欢”了页面。我不使用PHP,所以请只使用JS或Ruby

我不需要做任何fb connect的事情,也不需要知道他们是否喜欢我网站上的应用程序/页面。。。我所需要的一切都将通过iframe在facebook上进行

谢谢


[编辑:查看redbull的粉丝页面:这就是我想要做的]

得到了一个没有PHP的工作解决方案。感谢小矮人的启发

这不是一个JS解决方案,我不认为我感兴趣的事情可以用JS来完成,因为它涉及到跨站点脚本,这是一个禁忌。简言之,如果你想通过iframed应用程序判断某人是否喜欢你的页面,你必须以这样或那样的方式来消化签名请求

所以我的应用程序是Ruby on Rails。在FB方面,我将事情保持在沙箱模式,并在prod中工作/测试。不确定如何获得合适的本地环境进行测试。无论如何

  • 我安装/需要gem
  • 创建门控制器和视图:
    rails g控制器门索引fbindex
app/controllers/gate_controller.rb:

class GateController < ApplicationController
  def index
  end

  def fbindex
      app_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
      @signed_request = FBGraph::Canvas.parse_signed_request(app_secret, params[:signed_request])
  end
end
类网关控制器
app/views/gate/index.html.erb:

<h1>Gate#index</h1>
<p>Find me in app/views/gate/index.html.erb</p>

<form action="/gate/fbindex" method="post">

signed request: <input type="text" name="signed_request">
<input type="submit"/>
</form>
<h1>Gate#index</h1>
<p>Find me in app/views/gate/fbindex.html.erb</p>

<%= @signed_request.inspect %>


<% if @signed_request["page"]["liked"] %>
You like me!
<% else %>
You suck, cuz you don't like me
<% end %>
Gate#索引
在app/views/gate/index.html.erb中查找我

签名请求:
app/views/gate/fbindex.html.erb:

<h1>Gate#index</h1>
<p>Find me in app/views/gate/index.html.erb</p>

<form action="/gate/fbindex" method="post">

signed request: <input type="text" name="signed_request">
<input type="submit"/>
</form>
<h1>Gate#index</h1>
<p>Find me in app/views/gate/fbindex.html.erb</p>

<%= @signed_request.inspect %>


<% if @signed_request["page"]["liked"] %>
You like me!
<% else %>
You suck, cuz you don't like me
<% end %>
Gate#索引
在app/views/gate/fbindex.html.erb中查找我

你喜欢我! 你很烂,因为你不喜欢我
正确设置您的FB设置:
得到了一个没有PHP的工作解决方案。感谢小矮人的启发

这不是一个JS解决方案,我不认为我感兴趣的事情可以用JS来完成,因为它涉及到跨站点脚本,这是一个禁忌。简言之,如果你想通过iframed应用程序判断某人是否喜欢你的页面,你必须以这样或那样的方式来消化签名请求

所以我的应用程序是Ruby on Rails。在FB方面,我将事情保持在沙箱模式,并在prod中工作/测试。不确定如何获得合适的本地环境进行测试。无论如何

  • 我安装/需要gem
  • 创建门控制器和视图:
    rails g控制器门索引fbindex
app/controllers/gate_controller.rb:

class GateController < ApplicationController
  def index
  end

  def fbindex
      app_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
      @signed_request = FBGraph::Canvas.parse_signed_request(app_secret, params[:signed_request])
  end
end
类网关控制器
app/views/gate/index.html.erb:

<h1>Gate#index</h1>
<p>Find me in app/views/gate/index.html.erb</p>

<form action="/gate/fbindex" method="post">

signed request: <input type="text" name="signed_request">
<input type="submit"/>
</form>
<h1>Gate#index</h1>
<p>Find me in app/views/gate/fbindex.html.erb</p>

<%= @signed_request.inspect %>


<% if @signed_request["page"]["liked"] %>
You like me!
<% else %>
You suck, cuz you don't like me
<% end %>
Gate#索引
在app/views/gate/index.html.erb中查找我

签名请求:
app/views/gate/fbindex.html.erb:

<h1>Gate#index</h1>
<p>Find me in app/views/gate/index.html.erb</p>

<form action="/gate/fbindex" method="post">

signed request: <input type="text" name="signed_request">
<input type="submit"/>
</form>
<h1>Gate#index</h1>
<p>Find me in app/views/gate/fbindex.html.erb</p>

<%= @signed_request.inspect %>


<% if @signed_request["page"]["liked"] %>
You like me!
<% else %>
You suck, cuz you don't like me
<% end %>
Gate#索引
在app/views/gate/fbindex.html.erb中查找我

你喜欢我! 你很烂,因为你不喜欢我
正确设置您的FB设置:

嗨,cloudMagick。很抱歉问这个问题,但是您在“签名请求”中发送了什么?您需要该用户的令牌吗?你从哪儿弄来的?非常非常感谢。这个问题在stackoverflow上非常罕见,在rubyhi cloudMagick上也是如此。很抱歉问这个问题,但是您在“签名请求”中发送了什么?您需要该用户的令牌吗?你从哪儿弄来的?非常非常感谢。这个问题在stackoverflow上非常罕见,在ruby上也是如此