Class: Socialinfo::Core
- Inherits:
-
Object
- Object
- Socialinfo::Core
- Defined in:
- lib/socialinfo.rb
Instance Method Summary collapse
Instance Method Details
#all(url) ⇒ Object
20 21 22 |
# File 'lib/socialinfo.rb', line 20 def all(url) [:facebook, :twitter].each.inject({}) {|hash, key| hash[key] = send(key, url); hash } end |
#facebook(url) ⇒ Object
10 11 12 13 14 |
# File 'lib/socialinfo.rb', line 10 def facebook(url) xml = response_for "http://api.facebook.com/restserver.php?method=links.getStats&urls=#{url}" keys = %w{normalized_url share_count like_count comment_count total_count click_count} # comments_fbid keys.each.inject({}){|hash, k, v| hash[k] = $1 if xml.match(/<#{k}>(.*)<\/#{k}>/); hash } end |
#googleplus(url) ⇒ Object
18 19 |
# File 'lib/socialinfo.rb', line 18 def googleplus(url) end |
#twitter(url) ⇒ Object
15 16 17 |
# File 'lib/socialinfo.rb', line 15 def twitter(url) JSON.parse(response_for("http://urls.api.twitter.com/1/urls/count.json?url=#{url}")).reject{|k| k == 'url' } end |