Ruby:Twitter API:获取所有关注者

Rek*_*moc 4 ruby twitter

任何人都知道为什么下面的代码中的下一个光标没有改变?

cursor = "-1"
followerIds = []
while cursor != 0 do
 followers = Twitter.follower_ids("IDTOLOOKUP",{"cursor"=>cursor})

 cursor = followers.next_cursor
 followerIds+= followers.ids
 sleep(2)
end
Run Code Online (Sandbox Code Playgroud)

在第一次迭代,其中cursor = -1,它被分配来自twitter api的nextcursor.但是,当在后续迭代中将其发送到twitter API时,我得到的回复与我第一次使用相同的next_cursor相同.

我有什么想法我做错了吗?我正在使用twitter gem.

Ste*_*elm 8

编辑:[关于限速率删除的建议]

问题是follow_ids的游标选项.它应该是:

followers = Twitter.follower_ids("IDTOLOOKUP",{:cursor=>cursor})
Run Code Online (Sandbox Code Playgroud)

注意使用符号,而不是字符串.在原始代码中,提供的"cursor"选项被忽略,follower_ids正在执行默认行为,即返回关注者的第一页.