Introduction:
Hello Everyone, Let’s check out Twitter Bot using Python. So we’re gonna automate your Twitter account, you can add many functionally as you want and make it even cooler. Let’s get started….
Pre-requisites:
- First of all, create Twitter Developer Account for your Twitter Bot’s Account Here
- Fill up all details which are needed
- Get keys (API KEY, API KEY SECRET, ACCESS TOKEN, ACCESS TOKEN SECRET) from your Twitter Account
- Create Twitter App. Make Sure to give Read and Write Permission
- Create Heroku Account Here
I’ve already created one and deployed it on Heroku source code, It is tweeting already Here
Set-up on Machine
- Clone this Repository. (Make necessary changes in utils/tweet_it.py like set up while loop so it tweets the right message at right time)
- You can remove those greetings functions in tweet_it.py if you don't want them.
- open the tweet-it directory and type the below command
python3 -m venv twitter-bot && source environment/bin/activate
pip install -r requirements.txt
- Now it’s time to add Credentials. if you want to test this Twitter bot you can directly replace the key with your key. but if you want to deploy it then STOP, we have got a better approach.
Deploy
- Login to Heroku. Create new app
- Now go to settings and put your secret keys in the config vars section.
- Now open a terminal in your root directory of the project and login to Heroku from CLI.
heroku login
git init
heroku git:remote -a tweet-it
git add .
git commit -am "initial commit"
git push heroku master
- Now Most importantly set worker=1
heroku ps:scale worker=1
Now it should be running by now.
Thank You ☺️
Let me know if you are stuck somewhere while performing the above process