Ruby: Twitter API: Get All Subscribers

Does anyone know why the following cursor does not change in the code below?

cursor = "-1" followerIds = [] while cursor != 0 do followers = Twitter.follower_ids("IDTOLOOKUP",{"cursor"=>cursor}) cursor = followers.next_cursor followerIds+= followers.ids sleep(2) end 

After the first iteration, where cursor = -1, the next cursor from twitter api is assigned to it. However, when this is sent to the twitter API on subsequent iterations, I get the same answer as the first time .. with the same next_cursor.

Any ideas what I'm doing wrong? I use twitter stone.

+4
source share
1 answer

Edit: [Limited speed suggestion]

The problem is the follow_ids cursor option. It should read:

 followers = Twitter.follower_ids("IDTOLOOKUP",{:cursor=>cursor}) 

Note the use of the character, not the string. In the source code, the "cursor" parameter that was provided is ignored, and follower_ids performs the default behavior, namely, returns the first page of subscribers.

+8
source

Source: https://habr.com/ru/post/1332985/


All Articles