Module: Crown::TweetMeme
- Defined in:
- lib/crown/tweetmeme.rb
Class Method Summary collapse
-
.count(uri, proxy_host = nil, proxy_port = nil) ⇒ Object
——————————————————————- # count ——————————————————————- #.
Class Method Details
.count(uri, proxy_host = nil, proxy_port = nil) ⇒ Object
——————————————————————- #
count
——————————————————————- #
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/crown/tweetmeme.rb', line 46 def count(uri, proxy_host = nil, proxy_port = nil) begin session = Net::HTTP.new('api.tweetmeme.com', 80, proxy_host, proxy_port) path = '/url_info.json?url=' + CGI.escape(uri) response = Crown::HTTP.get(session, path) return nil if (response == nil || response.code.to_i != 200) json = JSON.parse(response.body) return json["story"]["url_count"].to_i rescue Exception => e return 0 end end |