Rack::Facebook::MethodFix - Facebook POST for Canvas fix

Blog Projects
Ruby Facebook

In early 2011 Facebook started to send all application requests as POST. Rack::Facebook::MethodFix converts POST requests back to GET when applicable. It 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.

Usage

When using Bundler add the following to your Gemfile:

gem "rack-facebook-method-fix"

Otherwise install the gem from commandline and require it in your code:

gem install rack-facebook-method-fix
require "rack-facebook-method-fix"

Then it is just matter of using the middleware.

use Rack::Facebook::MethodFix

Optionally if you want to validate contents of signed_request pass also the application secret.

use Rack::Facebook::MethodFix, :secret_id => "c561df165eacdd6e32672c9eaee10318"

You can exclude requests from being processed by adding an exclude option. To exclude all admin page requests you could do something like:

use Rack::Facebook::MethodFix, :exclude => proc { |env| env["PATH_INFO"].match(/^\/admin/) }

Fork me on GitHub



When asking a question include an URL to example page where the problem occurs. Even better is to make a Fiddle which demonstrates the problem. If you have longer code examples please use pastie.org.
CATEGORIES
Built using the awesome Flat UI Pro framework by Designmodo.

Mika Tuupola is a Member of the Leanpub Affiliate Program.

© 2014 Mika Tuupola.