Popularity searches social networks for a url and returns the metrics.
MIT License
Current support includes:
Network | Stats | Restriction |
---|---|---|
shares , comments
|
||
pins |
||
GooglePlus | plusones |
|
comments , score
|
||
Reddit Comments | score |
only for reddit comment urls |
Github | stars |
only for github repo urls |
Medium | recommends |
only for medium posts |
Soundcloud |
plays , likes , comments , downloads
|
only for soundcloud urls |
Rubygems | downloads |
only for rubygems |
> search = Popularity.search("http://google.com")
> search.facebook.shares #=> share count
> search.facebook.comments #=> comment count
> search.pinterests.pins #=> pin count
> search.reddit.posts #=> post count
> search.reddit.comments #=> comment count across all posts
> search.reddit.score #=> reddit score total across all posts
> search.total #=> All of the above numbers added up
Sometimes multiple URLs refer to the same thing. Maybe your URLs changed, but you don't want to lose out on counting those votes for the new location. Or you tweeted your blog address, but posted a link to soundcloud on reddit.
> search = Popularity.search("http://jeffkeen.me/p/I-know-its-you/", "http://soundcloud.com/jeffkeen/i-know-its-you")
> search.facebook.shares #=> share count across all urls
> search.facebook.comments #=> comment count across all urls
> search.pinterests.pins #=> pin count across all urls
> search.reddit.posts #=> post count across all urls
> search.reddit.comments #=> comment count across all posts and urls
> search.reddit.score #=> reddit score total across all posts and urls
> search.total #=> All of the above numbers added up
JSON:
> search.as_json
#=> spits out by network, by url, and total stats
To see which results a url came back with:
search = Popularity.search("https://medium.com/@jeffkeen/call-me-sometime-64ed463c02f0")
search.sources #=> [:facebook, :reddit, :google_plus, :pinterest, :twitter, :medium]
search.results #=> returns the individual network result classes, i.e. RedditPost, Medium, Soundcloud, Facebook
All of the searches done through Popularity.search are done asynchronously, but you don't need to worry about any of that because the method still blocks, so you can use it just like any other synchronous method.
To just query one network, interact with the class directly.
p = Popularity::RedditComment.new("http://www.reddit.com/r/path/to/reddit/comment")
p.score #=> comment score
Twitter discontinued support for the url count API.
Copyright (c) 2015 Jeff Keen. See LICENSE.txt for further details.