- post tweets from terminal like this
python3 twt.py "this tweet have been posted from my terminal"-
Get API keys from developer.twitter.com.
- Make a project/app, enable OAuth 1.0a
- Set to "Read and Write" perms (IMPORTANT)
- Copy your API Key and API Secret (also called
consumer_keyandconsumer_secret)
-
Create a file named
secrets.jsonin the same directory as the script.
{
"consumer_key": "your_api_key",
"consumer_secret": "your_api_secret"
}-
Paste this in your config file and replace
your_api_keyandyour_api_secretwith the actual keys you obtained from Twitter. -
Run the script for the first time, passing the tweet text as an argument:
python3 twt.py "{text}"- The script will output a URL like this, open it and authorize the app.
Please go here and authorize: https://api.twitter.com/oauth/authorize...- Twitter will give you a PIN code. Copy it and paste the PIN code into the script when it asks:
Paste the PIN here:- The script will complete the OAuth process and you will be able to post tweets using the script normally.
- Python 3.x installed
requests_oauthliblibrary installed
For more information about Twitter API OAuth, see:
Made with ♥ by 0xnotkyo