Skip to content

Instantly share code, notes, and snippets.

@ryanburnette
Created February 18, 2014 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanburnette/9083093 to your computer and use it in GitHub Desktop.
Save ryanburnette/9083093 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'uri'
require 'json'
class FacebookFetchShareCount
attr_accessor :uri
attr_reader :shares
def initialize(uri)
@uri = uri
@shares = false
end
def fetch_shares
uri = URI("http://graph.facebook.com/?id=" + @uri)
res = Net::HTTP.get(uri)
obj = JSON.parse(res)
if obj
return @shares = obj["shares"]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment