[Python] Post tweets using tweepy and Twitter API V2

Discussão em 'Python' iniciado por Stack, Julho 26, 2025.

  1. Stack

    Stack Membro Participativo

    I need my Twitter app to tweet some information, but something is going wrong. First, I created an app and tried this code to test credentials:

    auth = tweepy.OAuthHandler("CONSUMER_KEY", "CONSUMER_SECRET")
    auth.set_access_token("ACCESS_TOKEN", "ACCESS_SECRET")
    api = tweepy.API(auth)
    try:
    api.verify_credentials()
    print("Authentication Successful")
    except:
    print("Authentication Error")


    And got "Authentication Error". Then I tried to write a tweet directly using

    client = tweepy.Client(bearer_token, consumer_key, consumer_secret, access_token, access_token_secret)
    client.create_tweet(text="********")


    And now I got "tweepy.errors.Forbidden: 403 Forbidden" What should I do?

    Continue reading...

Compartilhe esta Página