Set Restriction Info with Facebooker 1

Posted by jcnnghm Tue, 22 Sep 2009 11:03:00 GMT

I’ve been working on a Facebook App and I was trying find out exactly how to go about setting content restrictions with Facebooker. While the documentation for the Admin.setRestricitionInfo API call is pretty clear, the Facebooker documentation is less clear.  It looked to me at first glance that the Facebooker::Admin.set_restriction_info method would have to be called with every request.  This seemed terribly innefecient to me, so I tried some other methods out until I found something that worked. In config/initializers, I created a facebook_permissions.rb file, and inserted the following code:

Facebooker::Admin.new(Facebooker::Session.create).set_restriction_info(‘type’ => ‘alcohol’)

This code will run every time your server starts, updating your application restriction settings.  Run the following command from script/console to double-check that the restrictions are being set correctly:

Facebooker::Admin.new(Facebooker::Session.create).get_restriction_info(‘type’)

Trackbacks

Use the following link to trackback from your own site:
http://littlebitofcode.com/trackbacks?article_id=17

  1. christophe Thu, 20 May 2010 06:33:19 GMT

    Thanks for writing this up. It was a great help.

    I had to tweak the getrestrictioninfo command slightly. This did the trick:

    Facebooker::Admin.new(Facebooker::Session.create).getrestrictioninfo.type