Joao Pedro Sedrez
Joao Pedro Sedrez

Reputation: 21

Permission of the API Twitter

I'm making a twitter bot to like tweets and at first the script is right. The problem is with the twitter API permission. It says "Read only" and there is no option to change it, as in the past. Anyone had the same problem? Always returns on console: "Read-only application cannot POST" Here is the script:

import tweepy

bearer_token = 'xxxxxxxxxx'
consumer_key = 'xxxxxxxxxxx'
consumer_secret = 'xxxxxxxxxxxx'
access_token = 'xxxxxxxxxxxxx'
access_token_secret = 'xxxxxxxxxxxxxxx'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)



api = tweepy.API(auth)


class MyStreamListener(tweepy.StreamListener):
    def on_status(self, tweet):
        # print("Tweet Found!")
        # print (f"{tweet.author.screen_name} - {tweet.text}")
        if tweet.in_reply_to_status_id is None and not tweet.favorited:
            try:
                print("Attempting like...")
                api.create_favorite(tweet.id)
                print("Tweet successfully liked :)")
            except Exception as err:
                print(err)
           
stream_listener = MyStreamListener()
stream = tweepy.Stream(auth=api.auth,listener=stream_listener)
stream.filter(track=["#NFTCommunity", "NFTCommunityCryptoArt"], languages=["en"])

Upvotes: 1

Views: 904

Answers (1)

anon
anon

Reputation:

As posted here.

In the developer portal:

  • select app name in sidebar -> app Settings page
  • User authentication settings -> Set up button
  • toggle on OAuth 1.0a
  • set Read and write App permissions permissions
  • specify URLs in general auth settings section. If you are not going to build a full sign-in with Twitter flow, you can use e.g. http://localhost here.
  • Save button

You will now need to select the Keys and tokens tab under the app settings, and Generate Access token and Secret, in order for them to have the new permissions.

(if this resolves your issue please mark this as the solution)

Upvotes: 2

Related Questions