Cookies and Facebook canvas apps

Posted: March 8th, 2011 | Author: | Filed under: Facebook, Rails | 5 Comments »

With the new Facebook way of loading iframes apps with POST requests, the safari third-party cookie problem is now partly fixed. It has always been a big headache dealing with cookies on the Facebook platform since Safari rejects them by default. With POST requests however, it is now possible to set cookies from the server. It seems Safari will still reject cookies set from the client.

So if you are using the Facebook Javascript SDK and set the cookies option to true, Safari won’t accept the FBS_XXXX cookie planted by the SDK. I struggled a whole week-end before figuring it out.

The work-around I use is to set a cookie from the server with the signed_request in it if there is one present. This solves most of the problems since I can just use the cookie when I don’t have a fresh signed_request (this happens when I do a request inside the canvas).

Here is the code inside a before_filter in the application_controller. I use Rails with the Facebooker2 gem :

The P3P header is used to make IE6 and IE7 accept the cookie as well.

If you’re building a Facebook canvas application with Rails, take the time to also read my post about keeping your REST architecture with the POST requests.


Restful Facebook canvas app with Rails and POST For Canvas

Posted: March 7th, 2011 | Author: | Filed under: Facebook | 9 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.


Create a Facebook poll

Posted: November 22nd, 2010 | Author: | Filed under: Facebook | 9 Comments »

I recently launched an application that lets you create your polls on Facebook and publish them on your fan page. This was something I wanted to do for a while since I thought there were no good polling apps on Facebook.

With Poll for Facebook, you can add as many questions as you want to your poll, images and invite your friends to answer it. There is a free and a Premium version.

I encourage you to try it and give me your feedback. It is now available in English, French, Spanish and German.