Class: Topsy::Client
Constant Summary collapse
- @@windows =
{:all => 'a', :week => 'w', :day => 'd', :month => 'm', :hour => 'h', :realtime => 'realtime'}
Instance Method Summary collapse
-
#author_info(url) ⇒ Topsy::Author
Returns Profile information for an author (a twitter profile indexed by Topsy).
-
#credit ⇒ Topsy::RateLimitInfo
Returns info about API rate limiting.
-
#experts(q, options = {}) ⇒ Hashie::Mash
Returns list of authors that talk about the query.
-
#link_post_count(url, options = {}) ⇒ Topsy::LinkpostCount
Returns count of links posted by an author.
-
#link_posts(url, options = {}) ⇒ Topsy::Page
Returns list of URLs posted by an author.
-
#related(url, options = {}) ⇒ Topsy::Page
Returns list of URLs related to a given URL.
-
#search(q, options = {}) ⇒ Topsy::Page
Returns list of results for a query.
-
#search_count(q) ⇒ Topsy::SearchCounts
Returns count of results for a search query.
-
#stats(url, options = {}) ⇒ Topsy::Stats
Returns counts of tweets for a URL.
-
#tags(url, options = {}) ⇒ Topsy::Page
Returns list of tags for a URL.
-
#trackbacks(url, options = {}) ⇒ Topsy::Page
Returns list of tweets (trackbacks) that mention the query URL, most recent first.
-
#trending(options = {}) ⇒ Topsy::Page
Returns list of trending terms.
-
#url_info(url) ⇒ Topsy::UrlInfo
Returns info about a URL.
Instance Method Details
#author_info(url) ⇒ Topsy::Author
Returns Profile information for an author (a twitter profile indexed by Topsy). The response contains the name, description (biography) and the influence level of the author
19 20 21 22 |
# File 'lib/topsy/client.rb', line 19 def (url) = handle_response(self.class.get("/authorinfo.json", :query => {:url => url})) Topsy::Author.new() end |
#credit ⇒ Topsy::RateLimitInfo
Returns info about API rate limiting
11 12 13 |
# File 'lib/topsy/client.rb', line 11 def credit handle_response(self.class.get("/credit.json")) end |
#experts(q, options = {}) ⇒ Hashie::Mash
Returns list of authors that talk about the query. The list is sorted by frequency of posts and the influence of authors.
32 33 34 35 |
# File 'lib/topsy/client.rb', line 32 def experts(q, ={}) = set_window_or_default() handle_response(self.class.get("/experts.json", :query => {:q => q}.merge())) end |
#link_post_count(url, options = {}) ⇒ Topsy::LinkpostCount
Returns count of links posted by an author. This is the efficient, count-only version of /linkposts
56 57 58 59 |
# File 'lib/topsy/client.rb', line 56 def link_post_count(url, ={}) count = handle_response(self.class.get("/linkpostcount.json", :query => {:url => url}.merge())) Topsy::LinkpostCount.new(count) end |
#link_posts(url, options = {}) ⇒ Topsy::Page
Returns list of URLs posted by an author
45 46 47 48 |
# File 'lib/topsy/client.rb', line 45 def link_posts(url, ={}) linkposts = handle_response(self.class.get("/linkposts.json", :query => {:url => url}.merge())) Topsy::Page.new(linkposts,Topsy::Linkpost) end |
#related(url, options = {}) ⇒ Topsy::Page
Returns list of URLs related to a given URL
68 69 70 71 |
# File 'lib/topsy/client.rb', line 68 def (url, ={}) response = handle_response(self.class.get("/related.json", :query => {:url => url}.merge())) Topsy::Page.new(response,Topsy::LinkSearchResult) end |
#search(q, options = {}) ⇒ Topsy::Page
Returns list of results for a query.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/topsy/client.rb', line 82 def search(q, ={}) if q.is_a?(Hash) = q q = "site:#{.delete(:site)}" if [:site] else q += " site:#{.delete(:site)}" if [:site] end = set_window_or_default() results = handle_response(self.class.get("/search.json", :query => {:q => q}.merge())) Topsy::Page.new(results,Topsy::LinkSearchResult) end |
#search_count(q) ⇒ Topsy::SearchCounts
Returns count of results for a search query.
98 99 100 101 |
# File 'lib/topsy/client.rb', line 98 def search_count(q) counts = handle_response(self.class.get("/searchcount.json", :query => {:q => q})) Topsy::SearchCounts.new(counts) end |
#stats(url, options = {}) ⇒ Topsy::Stats
Returns counts of tweets for a URL
109 110 111 112 113 114 |
# File 'lib/topsy/client.rb', line 109 def stats(url, ={}) query = {:url => url} query.merge!() response = handle_response(self.class.get("/stats.json", :query => query)) Topsy::Stats.new(response) end |
#tags(url, options = {}) ⇒ Topsy::Page
Returns list of tags for a URL.
123 124 125 126 |
# File 'lib/topsy/client.rb', line 123 def (url, ={}) response = handle_response(self.class.get("/tags.json", :query => {:url => url}.merge())) Topsy::Page.new(response,Topsy::Tag) end |
#trackbacks(url, options = {}) ⇒ Topsy::Page
Returns list of tweets (trackbacks) that mention the query URL, most recent first.
137 138 139 140 141 142 143 |
# File 'lib/topsy/client.rb', line 137 def trackbacks(url, ={}) results = handle_response(self.class.get("/trackbacks.json", :query => {:url => url}.merge())) results.list.each do |trackback| trackback.date = Time.at(trackback.date) end Topsy::Page.new(results,Topsy::Tweet) end |
#trending(options = {}) ⇒ Topsy::Page
Returns list of trending terms
151 152 153 154 |
# File 'lib/topsy/client.rb', line 151 def trending(={}) response = handle_response(self.class.get("/trending.json", :query => )) Topsy::Page.new(response,Topsy::Trend) end |
#url_info(url) ⇒ Topsy::UrlInfo
Returns info about a URL
160 161 162 163 |
# File 'lib/topsy/client.rb', line 160 def url_info(url) response = handle_response(self.class.get("/urlinfo.json", :query => {:url => url})) Topsy::UrlInfo.new(response) end |