This gem allows the user to access the fmylife.com API, which includes reading stories, reading comments, moderating stories that are submitted, submitting stories, submitting comments, and searching for stories.
In addition, this gem lets you swap in and out which XML parser you use. Since not everyone can take advantage of compiled xml parsers, the typically built-in REXML library is available as well.
The following code will connect with your API key, authenticate as a user, grab a page of the latest stories and then download all the comments for the very latest story. Then, it will print the names of each comment's author.
acc = FMyLife::Account.new("yourapikey") acc.authenticate(username,password) latest = acc.latest.first # get the latest story acc.story(latest) # pull comments acc.comments.each do |comm| puts comm.author end
More interestingly, we should be able to submit stories!
story = FMyLife::Story.new(:text => "my life sucks. FML", :author => "Anonymous", :category => :love)
See the individual docs for more examples.
gem install fmylife