Module: Twumper::Search
- Included in:
- Client
- Defined in:
- lib/twumper/search.rb
Constant Summary collapse
- BASE_URL =
"https://api.twitter.com/1.1/search/tweets.json"- DEFAULT_OPTIONS =
{ count: 100, limit: 200, result_type: 'mixed', max_id: nil }
Instance Method Summary collapse
Instance Method Details
#search(keyword, options = DEFAULT_OPTIONS) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/twumper/search.rb', line 12 def search(keyword, =DEFAULT_OPTIONS) tweets = Array.new while tweets.count < [:limit] url = "#{BASE_URL}?q=#{keyword}&result_type=#{[:result_type]}&count=#{[:count]}" url += "&max_id=#{[:max_id]}" if ![:max_id].nil? headers = set_headers response = connection.get(url, headers: headers) tweets += response['statuses'] [:max_id] = tweets.last['id'] end tweets end |