class TheCount::Facebook::Comments
Public Class Methods
new()
click to toggle source
# File lib/thecount/countable/facebook.rb, line 33 def initialize @service_name = "facebook" @unit = "comment" @value = 0 end
Public Instance Methods
count(data)
click to toggle source
# File lib/thecount/countable/facebook.rb, line 39 def count(data) url = data[:url] query = CGI::escape("\"index_link_stat_url\":\"select url,commentsbox_count from link_stat where url=\\\"#{url}\\\"\"") url = "https://api-read.facebook.com/restserver.php?format=json&method=fql.multiquery&queries=%7B#{query}%7D" begin @value = JSON.parse(open(url).string)[0]["fql_result_set"][0]["commentsbox_count"].to_i rescue Exception => e @value = 0 end end