RFacebook Updates!
Monday, July 30th, 2007It’s been awhile since my last blog post, but things haven’t exactly been quiet on the Facebook API front. There are tons of apps going up on Facebook every day, and its been pretty exciting. Hopefully RFacebook has been helping you all get your ideas out there.
There’s now an official home page for RFacebook:
http://rfacebook.rubyforge.org/
This will hopefully have the latest docs and information about the Gem. There has also been some updates to the API syntax:
“Facepricot” Responses
Every RFacebook API call returns a Facepricot document. This is a wrapper for an Hpricot XML document. Note that ALL of the standard Hpricot methods still apply (you can even grab the original Hpricot document via xml.hpricot and use the Hpricot stuff directly). However, a Facepricot document gives you some neat methods that simplify your code. Now, you don’t have to type this:
sess.friends_get.search("//uid").map{|xmlnode| xmlnode.inner_html} // get an array of all friend UIDs
sess.friends_get.at("//uid").inner_html // get the first UID of friends
Instead, you can type this:
sess.friends_get.uid_list // get an array of all friend UIDs sess.friends_get.uid // get the first UID of friends
Much cleaner. Hopefully that helps out.
Easier Logging
Another highly requested feature: logging. Now you can do:
sess.logger = MyLogger.new
or, if you use Rails
sess.logger = RAILS_DEFAULT_LOGGER
FacebookSession uses the “debug” log method on that logger to provide some useful behind-the-scenes information.
Caching
Yep, caching is built in now. If you make a call like cached_friends_get, the FacebookSession will automatically cache the response.