Class Topsy::Base
In: lib/rtopsy/base.rb
Parent: Object

provides all methods to the Topsy API

Methods

Included Modules

HTTParty

Public Class methods

returns the author info object according to the twitter url author_handle: eg. barackobama

[Source]

# File lib/rtopsy/base.rb, line 26
    def self.authorinfo(twitter_nick)
      resp = get_response("/authorinfo.json?url=http://twitter.com/#{twitter_nick}")
      Author.new(resp)
    end

returns a Page of results with a list of Author instances who talk most about the query parameter

[Source]

# File lib/rtopsy/base.rb, line 33
    def self.authorsearch(query = '', window = 'a')
      resp = get_response("/authorsearch.json?q=#{query}&window=#{window}")
      Page.new(resp, :author)
    end

performs a HTTParty get returns the response hash

[Source]

# File lib/rtopsy/base.rb, line 19
    def self.get_response(api_request)
      hash = get(api_request)  
      return hash["response"]
    end

returns a LinkpostCount for a nick twitter_nick: eg. barackobama

[Source]

# File lib/rtopsy/base.rb, line 49
    def self.linkpostcount(twitter_nick = '')
      resp = get_response("/linkpostcount.json?url=http://twitter.com/#{twitter_nick}")
      LinkpostCount.new(resp)
    end

returns a Page of results with a list of Linkpost instances twitter_nick: eg. barackobama page: eg. 1 perpage: eg. 12

[Source]

# File lib/rtopsy/base.rb, line 42
    def self.linkposts(twitter_nick = '', page = '1', perpage = '10')
      resp = get_response("/linkposts.json?url=http://twitter.com/#{twitter_nick}&page=#{page}&perpage=#{perpage}")
      Page.new(resp, :link_post)
    end

returns a Page of results with a list of LinkSearchResult returns nil if the window parameter is not correct

[Source]

# File lib/rtopsy/base.rb, line 63
    def self.search(query = '', window = :auto, page = 1, perpage = 10)
      if [:auto, :h, :d, :w, :m, :a].include? window
        resp = get_response("/search.json?q=#{query}&window=#{window}&page=#{page}&perpage=#{perpage}")
        Page.new(resp, :link_search_result)
      else
        nil
      end      
    end

returns a Stats instance for a certain url url: eg. aycron.com

[Source]

# File lib/rtopsy/base.rb, line 74
    def self.stats(url)
      resp = get_response("/stats.json?url=#{url}")
      Stats.new(resp)
    end

returns a UrlInfo instance for a certain url url: eg. aycron.com

[Source]

# File lib/rtopsy/base.rb, line 56
    def self.urlinfo(url)
      resp = get_response("/urlinfo.json?url=#{url}")
      UrlInfo.new(resp)
    end

[Validate]