Skip to content

Instantly share code, notes, and snippets.

@nkpoid
Last active August 29, 2015 14:27
Show Gist options
  • Save nkpoid/a34b0bfec1c287a3bcb0 to your computer and use it in GitHub Desktop.
Save nkpoid/a34b0bfec1c287a3bcb0 to your computer and use it in GitHub Desktop.
ruby twitter gemで5000件以上フォロー/フォロワーのidを取得するやつ
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