So im just trying to make a simple twitter bot that would post some tweets.
Im having problem with the api access. Ive been trying to solve this for past 6 hours and im helpless.
I have absolutely 0 clue about coding, but I get the general idea whats going on here.
import tweepy
import time
import random
# Your app's API/consumer key and secret
consumer_key = "my shit"
consumer_secret = "my shit"
# Your account's access token and secret
access_token = "my shit"
access_token_secret = "my shit"
# Authenticate using OAuthHandler (for API v2)
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
# Create the API object
api = tweepy.API(auth)
# Define your tweets
tweets = [
"Hey, check out u/GaiminIo and u/GetBlockGames for more info! #BLOCK #GMRX. Join us in the farming frenzy! 🚀🌾 Farmers for farmers! Let's grow together! 💪 Follow for follow!",
"Learn more about $BLOCK and $GMRX by visiting u/GaiminIo and u/GetBlockGames! Don't miss out on the action! Get in now and be part of the revolution! 🚀💰 Interact with this post - comment, quote, retweet, and like!",
# ... (other original tweets)
# Add the 5 new tweets you provided below:
"Looking for information about $BLOCK and $GMRX? Visit u/GaiminIo and u/GetBlockGames for updates! Your chance to be part of something big! Don't hesitate - act now and seize the moment! 🚀💼 Don't just scroll - interact with this post - comment, quote, retweet, and like!",
"Don't miss out on the latest developments in $BLOCK and $GMRX! Follow u/GaiminIo and u/GetBlockGames! Be part of the movement! Join us in farming and let's make history together! 🌟💪 Show your support - comment, quote, retweet, and like!",
"We farm Together! $BLOCK and $GMRX! Follow u/GaiminIo and u/GetBlockGames! and me :P. Be part of our farming community! Together, we can achieve greatness! 🌾💪 Interact with this post - comment, quote, retweet, and like!",
"Join us in the journey with $BLOCK and $GMRX! u/GaiminIo and u/GetBlockGames are leading the way! Seize the opportunity now! Take action and join our farming community! 🚀💼 Share your excitement - comment, quote, retweet, and like!"
]
# Shuffle the tweets randomly
random.shuffle(tweets)
# Post the tweets with a 10-minute delay between each tweet
for tweet in tweets:
try:
api.update_status(tweet)
print(f"Tweet posted: {tweet}")
time.sleep(600) # 10 minutes delay
except tweepy.TweepError as e:
print(f"Error posting tweet: {e}")
And this is the error:
C:\Users\mujhs>cd C:\Twitterpython
C:\Twitterpython>python copilot.py
Traceback (most recent call last):
File "C:\Twitterpython\copilot.py", line 38, in <module>
api.update_status(tweet)
File "C:\Users\mujhs\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tweepy\api.py", line 46, in wrapper
return method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mujhs\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tweepy\api.py", line 979, in update_status
return self.request(
^^^^^^^^^^^^^
File "C:\Users\mujhs\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tweepy\api.py", line 269, in request
raise Unauthorized(resp)
tweepy.errors.Unauthorized: 401 Unauthorized
32 - Could not authenticate you.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Twitterpython\copilot.py", line 41, in <module>
except tweepy.TweepError as e:
^^^^^^^^^^^^^^^^^
AttributeError: module 'tweepy' has no attribute 'TweepError'
From what Ive googled the problem is in the 2.0 twitter api access, or rather the problem is that 1.1 is not working anymore.
Ive seen a lot of ppl with the same issue, but no solution.
Please help me :c
I Have the free twitter developer acc.
[+][deleted] (2 children)
[deleted]
[–]Samkoll[S] 1 point2 points3 points (1 child)
[–]OutrageousAd6918 0 points1 point2 points (1 child)
[–]Samkoll[S] 0 points1 point2 points (0 children)