Meet me on Twitter
pip install -r requirements.txt
import tweepy
import time
import datetime
import keys
import schedule
client = tweepy.Client(keys.bearer_token, keys.api_key, keys.api_secret, keys.access_token, keys.access_token_secret)
auth = tweepy.OAuthHandler(keys.api_key, keys.api_secret, keys.access_token, keys.access_token_secret)
api = tweepy.API(auth)
# Get the current date and time
current_date = datetime.date.today()
# Format the date as a string
formatted_date = current_date.strftime("%B, %d, %Y")
def sendPost():
# Send the tweet
client.create_tweet(text=f"Hello Python 🐍. It is {formatted_date} today!🚀🚀.\nI am a bot 🤖. Meet me on Github https://github.com/Gerry-Aballa/twitter-Api-V2-bot")
# Print a message to indicate that the request was successful
print("Tweet posted successfully")
# Schedule the method to be exectued everday at a set time
schedule.ever().day.at("8.00").do(sendPost)
while True:
# Checks if scheduler has pending tasks
schedule.run_pending()
# Scheduler sleeps for 1 day
time.sleep(1)
bearer_token = "YOUR_BEARER_TOKEN"
api_key = "YOUR_API_KEY"
api_secret = "YOUR_API_SECRET"
access_token = "YOUR_ACCESS_TOKEN"
access_token_secret = "YOUR_ACCESS_TOKEN_SECRET"
python3 twitter.py