Last active
August 29, 2015 14:27
-
-
Save mxhold/0d6aa6629b799a22d1b3 to your computer and use it in GitHub Desktop.
Find the followers in common between two Twitter users
This file contains 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
#!/usr/bin/env ruby | |
# Usage: | |
# ./followers_in_common maxholder sandimetz | |
# You'll need to `gem install twitter` | |
require 'twitter' | |
# see: https://dev.twitter.com/oauth/overview/application-owner-access-tokens | |
client = Twitter::REST::Client.new do |config| | |
config.consumer_key = "CONSUMER_KEY" | |
config.consumer_secret = "CONSUMER_SECRET" | |
config.access_token = "ACCESS_TOKEN" | |
config.access_token_secret = "ACCESS_SECRET" | |
end | |
screen_name1 = ARGV.shift | |
screen_name2 = ARGV.shift | |
client.users( | |
[screen_name1, screen_name2] | |
.map { |screen_name| client.follower_ids(screen_name).to_a } | |
.reduce(:&) | |
) | |
.map { |user| [user.screen_name, user.name ] } | |
.map { |screen_name, name| puts "#{screen_name.ljust(20)}#{name}" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment