Last active
August 29, 2015 14:27
-
-
Save nkpoid/a34b0bfec1c287a3bcb0 to your computer and use it in GitHub Desktop.
ruby twitter gemで5000件以上フォロー/フォロワーのidを取得するやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "twitter" | |
rest = Twitter::REST::Client.new(key) #keyは各位適当に | |
def ff(method) | |
return if ![:friend_ids,:follower_ids].include? method | |
cursor = -1 | |
list = [] | |
until cursor == 0 | |
res = rest.send(method).to_h | |
list += res[:ids] | |
cursor = res[:next_cursor] | |
end | |
list | |
end | |
ff(:friend_ids) #=> Array | |
ff(:follower_ids) #=> Array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment