簡體   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