In early 2011 Facebook started to send all iframe application requests as POST. Because of this most REST based applications broke. Lets say you have object called
User. To get list of users in RESTful application you would issue the following request:
New user is created with POST request:
I’m sure you can spot the problem here. You try to retrieve list of users. That does not work. Instead you end up creating new object because your request was converted to POST.
Usually this could be fixed by sending the intended HTTP verb using
_method parameter. However it is not supported by Facebook.
Rack::Facebook::MethodFix middleware looks for incoming POST requests. If the request contains
signed_request parameter it converts request to GET as originally intended. Optionally if you pass in Facebook application secret_id it will also require the contents of
signed_request to be valid.
Install the gem by issuing command:
gem install rack-facebook-method-fix
After just it is just matter of requiring and using the middleware.
require "rack-facebook-method-fix" use Rack::Facebook::MethodFix
Optionally if you want to validate contents of signed_request pass also the application secret.
require "rack-facebook-method-fix" use Rack::Facebook::MethodFix, :secret_id => "c561df165eacdd6e32672c9eaee10318"
Related articles: Rake Tasks For Easier Facebook Development.