Download and install twython, using pip. I’m using python 3 so I typed the command
sudo pip3 install twython
Go to apps.twitter.com and create an account using your Twitter username and password.
Click ‘Create New App’
Fill in the mandatory fields and click next, if you don’t have a website just pop in a placeholder.
Once your app is created you will now will be brought through to a new page, click ‘Key and Access Tokens’.
Take note of the Consumer Key (API Key) and Consumer Secret (API Secret)
You will need to create an access token.
You should now see your access tokens, take note of these also.
Open up your favorite text editor, I’m using Idle, and enter the following:
from twython import Twython
APP_KEY = ‘YOUR_KEY_GOES_HERE’
APP_SECRET = ‘YOUR_SECRET_GOES_HERE’
OAUTH_TOKEN = ‘YOUR_TOKEN_GOES_HERE’
OAUTH_TOKEN_SECRET = ‘YOUR_TOKEN_SECRET_GOES_HERE’
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
twitter.update_status(status=’this is a test tweet from a python script!’)
Now run your script, if using Idle, you can do this by pressing F5.
Check Twitter to make sure your tweet has sent.