Fix for issue twitter4r/twitter4r-core#10
[twitter4r-core.git] / lib / twitter / client / search.rb
blob9f46c1c842a1f9fa1d5cb617b9dece917e08d502
1 class Twitter::Client
2   @@SEARCH_URIS = {
3     :basic => "/search.json",
4   }
6   # Provides access to Twitter's Search API.
7   # 
8   # Example:
9   #  # For keyword search
10   #  iterator = @twitter.search(:q => "coworking")
11   #  while (tweet = iterator.next)
12   #    puts tweet.text
13   #  end
14   # 
15   # All options will be passed on to the Twitter.com Search REST API
16   def search(options = {})
17     uri = @@SEARCH_URIS[:basic]
18     response = search_oauth_connect(:get, uri, options)
19     json = JSON.parse(response.body)
20     bless_models(Twitter::Status.unmarshal(JSON.dump(json["results"])))
21   end
22 end