Automate posting events from cal.nashvl.org to Twitter
- Create Twitter App (below)
- Add config variables for CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, and ACCESS_TOKEN_SECRET to your environment. The values of these variables should be copied from the Twitter page you left open in step 6 of "Create Twitter App"
python3 -m unittest tests/test_timer.py tests/test_twitter.py tests/test_event.py -v
python3 main.py
Prerequisites: Twitter and Heroku Accounts, Heroku CLI is installed, you are logged into Heroku via Heroku CLI
- Visit https://apps.twitter.com
- Login
- Create a new app
- Within your app visit the "Keys and Access Tokens" tab
- Generate your access token and access token secret
- Leave the page open, you will need it later
- Pull down nashDevTwitterBot
- cd into nashDevTwitterBot
- Ensure nashDevTwitterBot is initialized as a git repo. If not run
git init
within nashDevTwitterBot - Login into Heroku via a browser and create a new app
- Add a git remote for the Heroku app within nashDevTwitterBot Example:
heroku git:remote -a nash-dev-twitter-bot
- Push source to Heroku
git push heroku master
- Visit your Heroku App's "Settings" tab
- Locate the section "Config Variables"
- Add config variables for CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, and ACCESS_TOKEN_SECRET. The values of these variables should be copied from the Twitter page you left open in step 6 of "Create Twitter App"
- Go to your Heroku App's "Resources" tab
- Locate the "Add-ons" section
- Within the "Add-ons" section search for "Heroku Scheduler"
- Confirm it as an Add-on
- Click on "Heroku Scheduler"
- Click "Add new job"
- In the textfield paste in
python3 main.py
- Adjust "next due" to 14:00 UTC (9:00am CDT)
- Click save
- Test that everything is working by running
heorku run python3 main.py
- If it worked congrats! If not contact me at [email protected]
Cheers.