Class: Atig::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/atig/search.rb

Instance Method Summary collapse

Instance Method Details

#search(query, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/atig/search.rb', line 7

def search(query, options = {})
  search = URI("http://search.twitter.com/search.json")
  search.path = "/search.json"
  params = options; options[:q] = query
  search.query = options.to_query_str
  http = Http.new nil
  req = http.req(:get, search)
  res = http.http(search, 5, 10).request(req)
  res = JSON.parse(res.body)
rescue Errno::ETIMEDOUT, JSON::ParserError, IOError, Timeout::Error, Errno::ECONNRESET => e
  @log.error e
  text
end