parroty / extwitter

Twitter client library for elixir.
MIT License
409 stars 129 forks source link

The max_id on the search_metadata is incorrect #110

Closed foggy1 closed 5 years ago

foggy1 commented 5 years ago

Right now, if I perform ExTwitter.search("lol", count: 5, search_metadata: true), I get the following metadata payload:

%{
  completed_in: 0.013,
  count: 5,
  max_id: 1113508101062262784,
  max_id_str: "1113508101062262784",
  next_results: "?max_id=1113508099283750911&q=lol&count=5&include_entities=1",
  query: "lol",
  refresh_url: "?since_id=1113508101062262784&q=lol&include_entities=1",
  since_id: 0,
  since_id_str: "0"
}

Notice the difference between the max_id and the next_results max_id param. The thing listed as max_id is actually the latest tweet, as evidenced by its inclusion in the refresh_url field as the since_id. Grabbing the max_id out of next_results allows pagination to work properly: using the raw max_id field leads one to infinitely loop the same page.

When I get a chance I would be happy to PR a fix for this as well.

foggy1 commented 5 years ago

Whoops, Twitter API had me mixed up, it's the max_id of the response itself and then the next max id is in next results; closing