Skip to content

Instantly share code, notes, and snippets.

@abraham
Forked from dacort/chirp_friends.rb
Created April 9, 2010 01:31
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 abraham/360773 to your computer and use it in GitHub Desktop.
Save abraham/360773 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'yajl/http_stream'
require 'uri'
require 'open-uri'
USERNAME = 'username'
PASSWORD = 'password'
# If you've got a ton of either, you'll have to fork and cursor through
fr_ids = Yajl::HttpStream.get(URI.parse("https://api.twitter.com/1/friends/ids/#{USERNAME}.json"))
fo_ids = Yajl::HttpStream.get(URI.parse("https://api.twitter.com/1/followers/ids/#{USERNAME}.json"))
# Bring in the eventbrite list and search for twits
doc = open("http://www.eventbrite.com/rss/event_list_attendees/537658150").read
att = doc.scan(/What's your Twitter username\?: @?(\w+)/).flatten
# Map usernames to ids
u_by_id = {}
(0..att.length/100).each do |i|
l = i*100
u = (i*100)+99
# Yea, I didn't use https. Bad security guy!
Yajl::HttpStream.get(URI.parse("https://#{USERNAME}:#{PASSWORD}@api.twitter.com/1/users/lookup.json?screen_name=#{att[l..u].join(',')}")).each{|user|
u_by_id[user['id']] = user
}
end
# Who am I following that's going to Chirp?
ppl = (u_by_id.keys & fr_ids).collect{|id|
u_by_id[id]['screen_name']
}
# Who's following me that's going to Chirp?
pplf = (u_by_id.keys & fo_ids).collect{|id|
u_by_id[id]['screen_name']
}
# Mutual friends/followers?
pplm = (u_by_id.keys & fo_ids & fr_ids).collect{|id|
u_by_id[id]['screen_name']
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment