FbUtils
fb_utils is Ruby gem that lets you get and save facebook comments.
You can save comment in txt or csv file.
Installation
Type
gem install fb_utils
or
add this to your Gemfile and run the bundle command
gem 'fb_utils'
Usage
Get comments
If you need to just get comments, call get method with URL
# return Array of comments
comments = FbUtils::Comment.get('http://www.example.com')
comment = comments.first
puts comment.id #=> "388101711259_17396935"
puts comment. #=> "Hello world"
puts comment.created_time #=> "2011-07-26T01:23:34+0000"
puts comment.from_name #=> "Lukasz Kr"
puts comment.from_id #=> "123456789101112"
Save comments
In order to save comments in file system, call save method with URL and file name.
You can choose txt or csv file type (or write your own writer).
Default is txt.
# Save comments in example_com.txt file
FbUtils::Comment.save('http://www.example.com', 'example_com')
# Save comments in example_com.csv file
FbUtils::Comment.save('http://www.example.com', 'example_com', :format => :csv)
# For csv file you can pass additional parameters
FbUtils::Comment.save('http://www.example.com', 'example_com',
:format => :csv,
:fields_terminated_by => ";",
:fields_enclosed_by => "'",
:lines_terminated_by => "\n"
)
References
http://developers.facebook.com/docs/reference/plugins/comments/