Using Heroku's scheduler, post tweets at a regular interval.
This repo is forked from heroku_ebooks by @tommeagher. I wanted a stripped-down, bare-bones example of how to use the Twitter API with Heroku.
- Clone this repo
- Create a Twitter account that you will post to.
- Sign into https://dev.twitter.com/apps with the same login and create an application. Make sure that your application has read and write permissions to make POST requests.
- Make a copy of the
local_settings_example.py
file and name itlocal_settings.py
- Take the consumer key (and secret) and access token (and secret) from your Twiter application and paste them into the appropriate spots in
local_settings.py
. - Create an account at Heroku, if you don't already have one. Install the Heroku toolbelt and set your Heroku login on the command line.
- Type the command
heroku create
to generate the Python app. - The only Python requirement for this script is python-twitter, the
pip install
of which is handled by Heroku automatically. git commit -am 'updated the local_settings.py'
git push heroku master
- Test your upload by typing
heroku run worker
. Check your Twitter account to see if it worked. - Now it's time to configure the scheduler.
heroku addons:create scheduler:standard
(You'll need to add a credit card to your account if you haven't already - but don't worry, we'll be using the Free tier.) - Once that runs, type
heroku addons:open scheduler
. This will open up a browser window where you can adjust the time interval for the script to run. The scheduled command should bepython bot.py
. I recommend setting it at one hour. - Sit back and enjoy the fruits of your labor.