How to Make an Automatic Twitter Bot

By chaneya

Twitter

Did you know that many of the accounts that you follow and interact with on Twitter are actually not managed by people?

Well, it's true. Twitter provides a highly programmable API for developers and tinkerers that wish to write programs that interface with the system. In this post, you will see how to create an automatic Twitter bot for yourself.

Steps to Create Your Own Twitter Bot

1. Ensure you have Ruby and git installed (refer to Google or some other guide for help with this)

2. Clone this repository (https://github.com/netuoso/auto-twitter)

git clone https://github.com/netuoso/auto-twitter

3. Setup an application to get your API keys (https://apps.twitter.com/)

4. Configure your environment variables

export TWITTER_CONSUMER_KEY = '{{CONSUMER_KEY}}'
export TWITTER_CONSUMER_SECRET = '{{CONSUMER_SECRET}}'
export TWITTER_ACCESS_TOKEN = '{{ACCESS_TOKEN}}'
export TWITTER_ACCESS_SECRET = '{{ACCESS_SECRET}}'

5. Install required gem files

bundle install

6. Ensure the program is executable

chmod +x auto-twitter.rb

7. Test the setup to make sure everything is working

./auto-twitter.rb -a dev
rest_client.current_user.name

If everything above works, then you are good to go and ready to begin either customizing the bot, or streaming tweets immediately.
To stream tweets you can use either of the below commands:

./auto-twitter.rb -a stream
./auto-twitter.rb -a stream -b true

This will send the program to a background process so you can use close the terminal window)

Please make sure to leave any questions, comments, or recommendations in the area below. Open source development greatly improves when the community gets involved and helps each other out.

Tags

Latest Posts

RSS Feed

Rss feed 8ee173565b2e771fecf3b471a79bdf072aaa1bd9dc27582cfda2b2a322beeba8Subscribe

Archives