Skip to content

Instantly share code, notes, and snippets.

@mjfreshyfresh
Created November 11, 2009 20:30
Show Gist options
  • Save mjfreshyfresh/232265 to your computer and use it in GitHub Desktop.
Save mjfreshyfresh/232265 to your computer and use it in GitHub Desktop.
require 'nokogiri'
class CommentCounter
def self.num_comments(params, xids)
count = 0
facemask = Facemask.new(:api_key => ENV['FACEBOOK_API_KEY'], :session_key => params[:fb_sig_session_key], :secret_key => ENV['FACEBOOK_SECRET_KEY'])
xids.each do | xid |
result = facemask.post('facebook.comments.get', {:xid=>xid})
doc = Nokogiri::XML(result)
current_count = doc.search('comment').size
puts "xid: #{xid} count: #{current_count}"
count += current_count
end
puts "total: #{count}"
count
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment