有人知道为什么下一个光标在下面的代码中没有改变吗?
cursor = "-1"
followerIds = []
while cursor != 0 do
followers = Twitter.follower_ids("IDTOLOOKUP",{"cursor"=>cursor})
cursor = followers.next_cursor
followerIds+= followers.ids
sleep(2)
end
在 cursor = -1 的第一次迭代之后,它从 twitter api 分配了 nextcursor。但是,当在后续迭代中将其发送到 twitter API 时,我会得到与第一次相同的响应......使用相同的 next_cursor。
知道我做错了什么吗?我正在使用 Twitter gem 。
最佳答案
编辑:[关于删除速率限制的建议]
问题是 follow_ids 的游标选项。它应该是:
followers = Twitter.follower_ids("IDTOLOOKUP",{:cursor=>cursor})
注意使用符号,而不是字符串。在原始代码中,提供的“光标”选项被忽略,follower_ids 执行默认行为,即返回关注者的第一页。
关于Ruby:Twitter API:获取所有关注者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4505636/