To create a monitoring tool with Dashing, I want to display the number of LIKES of Facebook page in a widget. I retrieve the JSON with the necessary information :
{
"data": [
{
"share_count": 242039,
"like_count": 63648,
"comment_count": 52304,
"total_count": 357991
}
]
}
to view the number of like in a widget as in this example : https://github.com/Ephigenia/foobugs-dashboard#default-dashboard
How to display only the number of like in Ruby ?
I found something similar but uses Nokogiri https://github.com/Ephigenia/foobugs-dashboard/blob/master/jobs/twitter_user.rb
That would look like this:
require 'json'
# make the GET request
resp = Net::HTTP.get(URI("http://graph.facebook.com/fql?q=SELECT%20share_count,%20like_count,%20comment_count,%20total_count%20FROM%20link_stat%20WHERE%20url=%22http://www.google.fr%22&format=json"))
# parse the JSON into a ruby hash
json = JSON.parse(resp)
# pull the like_count value out of the response
puts json["data"][0]["like_count"]
=> 63648