繁体   English   中英

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

[英]Ruby: Twitter API: Get All followers

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

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})

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM