Skip to content

Instantly share code, notes, and snippets.

@brianc
Created March 12, 2010 21:57
Show Gist options
  • Save brianc/330843 to your computer and use it in GitHub Desktop.
Save brianc/330843 to your computer and use it in GitHub Desktop.
require 'json'
require 'httparty'
class Page
FBURL = "http://api.facebook.com/restserver.php"
APIVER = "1.0"
def self.fan_count
params = {
"method" => "Pages.getInfo",
"api_key" => KEY,
"v" => APIVER,
"fields" => "fan_count",
"page_ids" => "21956400441",
"format" => "JSON" }
arg_string = params.sort.inject("") { |a,b| a << b.join("=") }
params["sig"] = Digest::MD5.hexdigest("#{arg_string}#{SECRET}")
response = HTTParty.post(FBURL,:body => params)
JSON.parse(response.body)[0]["fan_count"]
end
end
while true do
puts "#{Time.now} => #{Page.fan_count}"
sleep(300)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment