Skip to content

Instantly share code, notes, and snippets.

@yoggy
Created December 18, 2010 05:49
Show Gist options
  • Save yoggy/746208 to your computer and use it in GitHub Desktop.
Save yoggy/746208 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
#
# twitter_protected_unfollow.rb
#
# http://rubydoc.info/gems/twitter/1.0.0/file/README.mkd
#
require 'rubygems'
require 'twitter'
require 'pp'
CONSUMER_KEY=
CONSUMER_SECRET="????"
ACCESS_TOKEN="????"
ACCESS_TOKEN_SECRET="????"
Twitter.configure do |cf|
cf.consumer_key = "????"
cf.consumer_secret = "????"
cf.oauth_token = "????"
cf.oauth_token_secret = "????"
end
# protected users listing
protected_users = []
c = Twitter.friends()
count = 0
loop do
c.users.each{|u|
protected_users << u if u.protected == true
}
break if c.next_cursor == 0
c = Twitter.friends(:cursor => c.next_cursor)
count += 1
puts "fetch count = #{count}"
sleep 3
end
# unfollow
print "unfollow users: "
print protected_users.map{|u| u.screen_name}.join(", ")
puts
protected_users.each do |u|
Twitter.unfollow(u.screen_name)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment