Reputation: 3203
I am trying to get the likes from a company pages (coca-cola) I used this code but console report error "no such file and directory"
def facebook_likes()
data = open("http://graph.facebook.com/40796308305").read
data = JSON.parse(data)
@likes = data['likes']
end
Upvotes: 1
Views: 1087
Reputation: 902
Try something like this:
require 'net/http'
def facebook_likes
uri = URI("http://graph.facebook.com/40796308305")
data = Net::HTTP.get(uri)
@likes = JSON.parse(data)['likes']
end
Upvotes: 3