sferik/t — pull request #32 by jphpsf (2012-05-02 16:44:55+00:00)
Title: Add support for getting more than 200 favorites

Hi

When I was playing with the favorites command, I noticed that it did not retrieve more than the first 200. It seems to be a limitation of the twitter API where it only returns a maximum of 200 favorites per API call. It was a bit confusing as I happen to have more than 200 favorites on my Twitter profile. I was trying to pass `-n 400` to get all my favorites but I kept getting the same first 200.

The twitter gem has a pagination option that allows to work around this limitation. This pull request changes the favorites command to make use of pagination. By default it will query for the first page and if the `-n` option is greater than 200, it will query for subsequent pages. Example: I have 352 favorites. If I call the CLI with `-n 400`, it will request page 1 and then page 2.

What do you think of this behavior? Do you think this behavior should be added to other commands (I noticed other APIs like mentions or timeline have maximum limitations)?

Note that this pull request is incomplete. I wanted to get your opinion before moving forward. I'd like to clean up:
1) Add tests ;)
2) Fix the issue where it would eventually do more API calls than needed: with my 352 favorites, if I run with `-n 1000`, it will make 5 API calls (1000 divided by 200) but the 3 last calls are useless (the 2 first calls are enough to get all my favorites).
3) Investigate an odd issue: while the whois command tells me that I have 352 favorites, the favorites command only return 334.