Follower.ids endpoint never returning next_cursor = 0?


#1

I’m sure I’m just overlooking something simple, but this code ought to return follower ids in groups of 5000 and then exit the loop when the last id is collected and next_cursor is returned as 0, as per https://dev.twitter.com/docs/misc/cursoring.

Here is my code - it assumes that you have t set as your authorized api url, and user_id is set to the target user’s id:

follower_ids=[]
cursor = -1
while cursor != 0:
    for retries in range (0,5):  # error catching in case of rate limit
        try:
            response = t.followers.ids(user_id = user_id)
            print len(response['ids'], "follower ids collected".
            break
        except:
            "Rate limit reached.  Trying again in 5 minutes".
            time.sleep(300)
    follower_ids.append(response['ids'])
    cursor = response['next_cursor']
    print "Next cursor is ", cursor

print "Run complete.", len(follower_ids), "follower ids collected."

However, when I run this, the call to followers.ids never returns a next_cursor of 0. Once all the follower ids have been retrieved, it just keeps returning the same last 5000 follower ids and the same long next_cursor number over and over.

Am I just overlooking something simple in my loop? Been staring at it so long, I’m sure it’s probably something simple.

Arrrrrggggg.