1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Here's a Twitter Follower Script

Discussion in 'Social Networking Sites' started by fadeawayjay420, May 4, 2013.

  1. fadeawayjay420

    fadeawayjay420 Newbie

    Joined:
    Mar 14, 2013
    Messages:
    8
    Likes Received:
    0
    Hi all,

    I just wrote this and thought it may be useful for some. It searches twitter and follows users who mention a given keyword. I'm not going to help you use it as it's pretty self explanatory. Enjoy.

    Code:
    #!/usr/bin/env rubyrequire 'twitter'
    class Twibot
        def initialize(arguments, stdin)        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    end
        def follow(keyword)      Twitter.search(keyword, :rpp => 100, :result_type => "recent").results.map do |status|         Twitter.follow("#{status.from_user}")         puts "Followed #{status.from_user}"
             rnd = Random.new(Time.now.to_i % 10)         result = rnd.rand(60..70)                  sleep(result)      end
          self.follow(keyword)    end
        def run        self.follow("{ENTER KEYWORD TO SEARCH FOR}")    end      end
    app = Twibot.new(ARGV, STDIN)app.run
    
     
    Last edited: May 4, 2013
  2. fadeawayjay420

    fadeawayjay420 Newbie

    Joined:
    Mar 14, 2013
    Messages:
    8
    Likes Received:
    0
    Sorry for the awful formatting, this forum killed all the whitespace in the code tags and won't let me post a link to a formatted version.