Added v 0.3.1 snapshot.
[twitter4r-core.git] / lib / twitter / client / search.rb
blob416ea5f21591ee15a27f0dfe1d91903ee03136d5
1 class Twitter::Client
3   @@SEARCH_URIS = {
4     :basic => "/search.json",
5   }
7   # Provides access to Twitter's Search API.
8   # 
9   # Example:
10   #  # For keyword search
11   #  iterator = @twitter.search(:q => "coworking")
12   #  while (tweet = iterator.next)
13   #    puts tweet.text
14   #  end
15   # 
16   # An <tt>ArgumentError</tt> will be raised if an invalid <tt>action</tt> 
17   # is given.  Valid actions are:
18   # * +:received+
19   # * +:sent+
20   def search(options = {})
21 #    raise ArgumentError, "Invalid messaging action: #{action}"
22     uri = @@SEARCH_URIS[:basic]
23     response = http_connect(nil, false, :search) {|conn|        create_http_get_request(uri, options) }
24     json = JSON.parse(response.body)
25     bless_models(Twitter::Status.unmarshal(JSON.dump(json["results"])))
26   end
27 end