The following code is a ruby version of “auto-follow” script introduced in the previous post: How to Auto Follow on Twitter by Twitter API & PHP.
Whole Code for Twitter Auto-Follow
#!/usr/bin/ruby require 'rubygems' require 'twitter' USERNAME = 'your_twitter_username' CONSUMER_KEY = 'your_consumer_key' CONSUMER_SECRET = 'your_consumer_secret' OAUTH_TOKEN = 'your_oauth_token' OAUTH_TOKEN_SECRET = 'your_oauth_token' client = Twitter::Client.new( :consumer_key => CONSUMER_KEY, :consumer_secret => CONSUMER_SECRET, :oauth_token => OAUTH_TOKEN, :oauth_token_secret => OAUTH_TOKEN_SECRET ) follower_ids = [] client.follower_ids(USERNAME).each do |id| follower_ids.push(id) end friend_ids = [] client.friend_ids(USERNAME).each do |id| friend_ids.push(id) end client.follow(follower_ids - friend_ids)