Restful Facebook canvas app with Rails and POST For Canvas
Posted: March 7th, 2011 | Author: Pierre Olivier Martel | Filed under: Facebook | 12 Comments »Update: The rack middleware is now included in Facebooker2. If you’re using Facebooker2, see the readme for details.
Starting March 10th, The POST for canvas option will become mandatory for all Facebook canvas apps. This means all requests to your iframe originating from the Facebook frame will be POST requests. If you use restful controllers in your app, this is not a good news. Fortunately, there is a very easy way to convert those POST back to GET with a Rack middleware :
Since all request coming from Facebook will include a signed_request parameter, you can assume that these requests are coming from the top frame. Other requests made directly from your iframe won’t be altered. You can safely now safely use Post for canvas and continue to assume all requests coming from the top frame will be get requests.
Passionate web entrepreneur living in Montreal and hacking (mostly) Facebook apps with Ruby on Rails.
Pingback: Cookies and Facebook canvas apps | redirect_to :hack