Skip to content

Instantly share code, notes, and snippets.

@satococoa
Created July 18, 2014 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satococoa/6f65c6427aed3cbfa455 to your computer and use it in GitHub Desktop.
Save satococoa/6f65c6427aed3cbfa455 to your computer and use it in GitHub Desktop.
sougo_follow.rb
# usage
# $ ruby sougo_follow.rb satococoa
# follower_ids も friend_ids も rate_limit が厳しいので注意
require 'bundler/setup'
Bundler.require
screen_name = ARGV[0]
client = Twitter::REST::Client.new do |config|
config.consumer_key = ''
config.consumer_secret = ''
config.access_token = ''
config.access_token_secret = ''
end
redis = Redis.new
redis.del 'followers'
redis.del 'followings'
begin
res = client.follower_ids(screen_name)
redis.sadd 'followers', res.attrs[:ids]
end until res.attrs[:next_cursor_str].to_i == 0
begin
res = client.friend_ids(screen_name)
redis.sadd 'followings', res.attrs[:ids]
end until res.attrs[:next_cursor_str].to_i == 0
sougo_follows = redis.sinter 'followers', 'followings'
puts "相互フォロー: #{sougo_follows.count} 人"
puts "id: #{sougo_follows.join(', ')}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment