I'm using https://dev.twitter.com/docs/api/1.1/post/lists/members/create_all and https://dev.twitter.com/docs/api/1.1/post/lists/members/destroy_all which both claim a limitation of 100 users per call. I limit my calls to 90 users, but I still intermittently receive a
Too many terms specified in query error ... I'll even intermittently get this error when I limit my calls to 40 users or less.
It seems to apply only to certain users that I make the call on behalf of: I can iterate over some users just fine with my 90-user limit, but some of the users I iterate over will error out with
Too many terms specified in query unless I severely limit my calls (for example, 10 users at a time) ... but that severe limitation just presents a different problem - I hit Rate Limit when I try to make so many small calls for the user.
I'm iterating over each user in my database with
User.all.each do |u|, and I'm creating a connection to Twitter for each user within that block with:
client = Twitter::Client.new(
:consumer_key => TWITTER_CONSUMER_KEY,
:consumer_secret => TWITTER_CONSUMER_SECRET,
:oauth_token => u.twitter_token,
:oauth_token_secret => u.twitter_secret
This is the code I use to remove users from a list:
removing_from_list.each_slice(90) do |remove_ids|
and this code to add users to a list:
adding_to_list.each_slice(90) do |adding_ids|
I've experienced this issue both in use of the Twitter gem as well as by accessing the Twitter API directly with Rested (a Mac REST client).