Has a lots of API endoints.
You can see some of the public ones here:
https://dev.twitter.com/rest/public
For this session, we'll be focusing on the post Twitter API.
https://dev.twitter.com/rest/reference/post/statuses/update
That's a lot to take into account!
Twython makes all of these API calls and responses easy to navigate.
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
twitter.update_status(status="Tweet String")
To generate keys for your new bot, you'll need to create a new Twitter account first!
You can then go to https://apps.twitter.com/ to create a new application.
Twitter needs to verify that the app builder (you) has permission to post tweets to a specific account.
The App Keys are related to your application and the Oauth Keys are specific to the user.
Since we're building an app to access and update our own bot's data, we can generate all the keys ourselves.
I've created a testing bot, @pyladiesatx_bot, for all of us to use during this workshop.
You are welcome to create your own, or you can use the keys for our testing bot here:
Twitter API Keys
Setup your environment and project per the README file in the git repository and run the code once to see how it works.
https://github.com/bluflowr/twitterbot_workshop
Change the make_tweet function.
There are many ways to schedule your bot. Heroku has a free scheduler you can read about. For today's workshop we'll attempt to setup a cron job on our laptops. As long as they're running and internet connected, your computer can automatically run a script for you.
crontab -e
0 5,17 * * * cd /Path/to/your/code && source YOURenv/bin/activate && python tweet.py
Irma Kramer
@bluflowr
irma@irmakramer.com