Specifying REST search number of results

48 views
Skip to first unread message
Assigned to sfe...@gmail.com by me

Ryan Williams

unread,
Mar 1, 2014, 1:30:58 AM3/1/14
to twitter-...@googlegroups.com
I've encountered an unexpected result, hoping to understand this a little better. When executing a search with a count:

client.search("#sometag -RT -via", :result_type => "recent", :count => 100).each do |tweet|

I see 2 HTTP requests made to the API, the first with the count param and the second with and addition max_id parameter, it is clearly paging, but that was the unexpected part. With the take() and no count, it executes a single result.

client.search("#sometag -RT -via", :result_type => "recent").take(100).each do |tweet|


Is the idea to just use take in the simplest case, when not worrying about paging?

sferik

unread,
Mar 1, 2014, 2:28:26 AM3/1/14
to twitter-...@googlegroups.com
The idea is to provide a nicer interface to Twitter by abstracting the HTTP layer. You, the consumer, shouldn’t have to think about how many HTTP requests are being made under the hood. Just tell the gem what you want and let it worry about how to best deliver those results. Most of the time, it will do the optimal thing. In the cases where it does not, the gem also provides an HTTP interface (but the hope is that you rarely—if ever—have to use this directly).
Reply all
Reply to author
Forward
0 new messages