Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Post tweet with tweepy

I'm trying to post a tweet with the tweepy library. I use this code:

import tweepy

CONSUMER_KEY ="XXXX"
CONSUMER_SECRET = "XXXX"   
ACCESS_KEY = "XXXX"    
ACCESS_SECRET = "XXXX"

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)

api = tweepy.API(auth)
api.update_status('Updating using OAuth authentication via Tweepy!')

But when I run the application, I receive this error:

raise TweepError(error_msg, resp)
TweepError: Read-only application cannot POST.

How can I fix this?

like image 534
Riccardo Gai Avatar asked Oct 12 '13 18:10

Riccardo Gai


People also ask

How do I post a tweet to API?

First, log in to the Twitter developer's portal with the account from which you want to post a tweet. Then click on the "Developer Portal" link in the upper right corner. Once you enter it, click on "Projects & Apps" -> "Overview" -> "Create App".

Is Tweepy deprecated?

Deprecated since version 4.10: The Twitter API v1. 1 endpoint this method uses is now deprecated and will be retired on October 29, 2022.

How do you send a tweet in Python?

Send a tweet from PythonSave the file as auth.py . Save this file as twitter.py . This uses the API's update_status() function to send a tweet containing the text “Hello world!”. Now save ( Ctrl + S ) and run with F5 .

How many tweets can Tweepy extract?

Tweepy provides the convenient Cursor interface to iterate through different types of objects. Twitter allows a maximum of 3200 tweets for extraction.


1 Answers

In the application's settings, set your Application Type to "Read and Write". Then renegotiate your access token.

like image 134
user2737086 Avatar answered Dec 01 '22 16:12

user2737086