I recently created a Twitter account, and I want to access weather-related information using an API. In the developer section, under the “Overview” section, it says following.
LIMITED V1.1 ACCESS ONLY Standalone Apps live outside of Projects. This means that they can’t use the the most current v2 Twitter API endpoints.
And after I enter the following code in Python:
Forbidden: 403 Forbidden 453 - You currently have access to Twitter API v2 endpoints and limited v1.1 endpoints only. If you need access to this endpoint, you may need a different access level. You can learn more here: Getting Started with the Twitter API | Docs | Twitter Developer Platform
import tweepy
API_KEY = '----'`your text`
API_SECRET_KEY = '----'
ACCESS_TOKEN = '---'
ACCESS_TOKEN_SECRET = '---'
auth = tweepy.OAuthHandler(API_KEY, API_SECRET_KEY)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
def get_followers_count(screen_name):
user = api.get_user(screen_name=screen_name)
return user.followers_count
screen_name = 'account_x'
followers_count = get_followers_count(screen_name)
print(f'The number of followers for {screen_name} is: {followers_count}')