Skip to content

Instantly share code, notes, and snippets.

@bcardarella
Created May 30, 2011 18:29
Show Gist options
  • Save bcardarella/999261 to your computer and use it in GitHub Desktop.
Save bcardarella/999261 to your computer and use it in GitHub Desktop.
Quickly find out who among the people you follow are not following you back
require 'twitter'
# You'll need to get this info from your Twitter Developer account
Twitter.configure do |config|
config.consumer_key = YOUR_CONSUMER_KEY
config.consumer_secret = YOUR_CONSUMER_SECRET
config.oauth_token = YOUR_OAUTH_TOKEN
config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
end
# Grab a collection of ids for your friends and your followers
friends = Twitter.friend_ids.ids
followers = Twitter.follower_ids.ids
# screen_names is a collection of users who you are following but are not following you back
screen_names = Twitter.users(*(friends - followers)).map(&:screen_name)
@sferik
Copy link

sferik commented Jun 4, 2011

A couple notes:

  • This will only work for users with <= 5,000 friends/followers. If you have more than that, you need to use cursors.
  • Line 16 will only fetch up to 100 users. If you want to implement this correctly, you need to batch users into groups of 100.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment