Код: Выделить всё
# V1 Twitter API Authentication
auth = tweepy.OAuthHandler(api_key, api_key_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth, wait_on_rate_limit=True)
# V2 Twitter API Authentication
client = tweepy.Client(
bearer_token,
api_key,
api_key_secret,
access_token,
access_token_secret,
wait_on_rate_limit=True,
)
# Upload image to Twitter. Replace 'filename' your image filename.
media_id = api.chunked_upload(filename="Pledge.mp4",
media_category="tweet_video").media_id_string
print(media_id)
# Text to be Tweeted
text = "Hello Twitter!"
# Send Tweet with Text and media ID
client.create_tweet(text=text, media_ids=[media_id])
print("Tweeted!")
Код: Выделить всё
1843760094611189760
Traceback (most recent call last):
File "C:\Users\pablo\Desktop\ai-agents\projects\final_try\twitterbot_karaoke_deploying\aaa\e.py", line 84, in
client.create_tweet(text=text, media_ids=[media_id])
File "C:\Users\pablo\anaconda3\Lib\site-packages\tweepy\client.py", line 835, in create_tweet
return self._make_request(
^^^^^^^^^^^^^^^^^^^
File "C:\Users\pablo\anaconda3\Lib\site-packages\tweepy\client.py", line 129, in _make_request
response = self.request(method, route, params=request_params,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\pablo\anaconda3\Lib\site-packages\tweepy\client.py", line 96, in request
raise BadRequest(response)
tweepy.errors.BadRequest: 400 Bad Request
Your media IDs are invalid.
Подробнее здесь: https://stackoverflow.com/questions/790 ... epy-python