For the past few days, I’ve been trying to create a Facebook application for interacting with Github. I hoped to spend my time mainly on the Github portion, figuring out how to post wall posts on Facebook about recent Github activity, etc. However, I’ve instead argued with the various Facebook APIs. I started out using PHP with no framework but quickly switched to CakePHP after I realized things were going to get hairy. CakePHP was okay for a while until I hit the roadblock of not being able to load any page but the index… Every sub-page I tried to create produced 404 errors, which no one else seemed to have (or at least document), so I said ‘screw it’ and switched to Rails.

I started out using the Facebooker API but got frustrated when I kept getting an error about not being able to convert nil to String. I don’t even know now what was causing that. I tried various ways of accessing Facebooker, via gem or plugin (though one of the developers says in this forum that he hadn’t rebuilt the gem in a while, so use the plugin), with no luck. So I switched to the older RFacebook and had troubles accessing the magical “fbsession” that every tutorial in the history of RFacebook tutorials glosses over like of course it’s available in your controller and if it’s not then you’re obviously retarded and should just write Visual Basic for the rest of your pitiful programming career. Again, screw that. Feeling hopeless at the lack of other Ruby APIs out there for Facebook, I went back to Facebooker and proceeded to get 422 Unprocessable Entity errors (?!) whenever I would submit a POST request. In my logs, I was seeing the following:

ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
  facebooker (1.0.61) [v] lib/facebooker.rb:90:in `with_application'

Lots of googling led to the aforelinked forum post wherein someone said to turn off forgery protection by commenting out the following line in app/controllers/application_controller.rb

protect_from_forgery # See ActionController::RequestForgeryProtection for details

That doesn’t sound good, turning off forgery protection, but the forum poster said Facebook already provides it. No idea if that’s true, but by damn, I just want to POST two string values to update the database! Sheesh! Anyway, so my posts work now and things are proceeding along as I would have expected them to three days ago.