Do we have to have a paid developer account to read users' twitter DMs through their official API?
I signed up for the free account and I wrote a simple Tweepy script which throws the following error. I am working on a hobby project to read twitter DMs and feed them to an LLM to retrieve information.
import tweepy
import webbrowser
import os
from urllib.parse import parse_qs, urlparse
from dotenv import load_dotenv
load_dotenv('twitter.env')
CONSUMER_SECRET = os.getenv('API_KEY_SECRET')
CONSUMER_KEY = os.getenv('API_KEY')
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
try:
redirect_url = auth.get_authorization_url()
webbrowser.open(redirect_url)
except tweepy.TweepError:
print('Error! Failed to get request token.')
url = input('Paste the entire URL you were redirected to: ')
parsed_url = urlparse(url)
parsed_qs = parse_qs(parsed_url.query)
if 'oauth_verifier' in parsed_qs:
verifier = parsed_qs['oauth_verifier'][0]
else:
print("Couldn't find the oauth_verifier in the provided URL!")
exit()
try:
auth.get_access_token(verifier)
except tweepy.TweepError:
print('Error! Failed to get access token.')
api = tweepy.API(auth)
direct_messages = api.get_direct_messages(count=10)
for dm in direct_messages:
print(dm.message_create['message_data']['text'])
Error
tweepy.errors.Forbidden: 403 Forbidden
453 - You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product