添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hello,

I am attempting to retrieve tweets using Python and the Twitter API, and I keep getting this error
‘tweepy.errors.Forbidden: 403 Forbidden’. I have a developer account, and I triple checked my keys and tokens, and they’re correct. Please help me if you know how to approach this issue.

Thanks.

MY PYTHON SCRIPT IS PASTED BELOW (Not sure what I am doing wrong).

import tweepy
import textblob
import pandas as pd
import numpy as np
import re
import matplotlib.pyplot as plt

API Keys & Tokens

api_key= “xxxx”
api_key_secret= “xxxx”
access_token=‘xxxx’
access_token_secret=‘xxxx’

Creating Authentication object

authenticator = tweepy.OAuthHandler(api_key, api_key_secret)
authenticator.set_access_token(access_token, access_token_secret)

Creating API object

api = tweepy.API(authenticator, wait_on_rate_limit=True)

We will search for bitcoin related tweets and disregard retweets

crypto_coin = “bitcoin”
search_term = f’#{crypto_coin} -filter:retweets’

Creating cursor object

tweet_cursor = tweepy.Cursor(api.search_tweets, q= search_term, lang=‘en’,
tweet_mode=‘extended’).items(100)

tweets = [tweet.full_text for tweet in tweet_cursor]

Thanks for reaching out here. I was able to get the following script to run locally for me with my own keys and tokens.

import tweepy
api_key = ""
api_key_secret = ""
access_token = ""
access_token_secret = ""
authenticator = tweepy.OAuthHandler(api_key, api_key_secret)
authenticator.set_access_token(access_token, access_token_secret)
api = tweepy.API(authenticator, wait_on_rate_limit=True)
crypto_coin = "bitcoin"
search_term = f'{crypto_coin} -filter:retweets'
tweet_cursor = tweepy.Cursor(api.search_tweets, q= search_term, lang="en",
tweet_mode="extended").items(100)
tweets = [tweet.full_text for tweet in tweet_cursor]
print(tweets)

This error usually comes when the request is understood, but it has been refused or access is not allowed. An accompanying error message will explain why. Check that your developer account includes access to the endpoint you’re trying to use.

I’m also interested to hear from you what access level you have, you can find that on this page of the Portal.

Ah, so with essential access, you don’t have access to our v1.1 endpoints. However, there is a chart which you might find helpful. Tweepy does support v2 endpoints, which might also be an option for you as well.

Best,

Jessica

Awesome. Thanks for your response. I did request elevated access, and now my script runs just fine. Again, I really appreciate your help with this.

Best,
Santi

helloo…
i have same problem…
so it’s mean tweepy python’s library doesn’t work in essential access.
would you share how to request to upgrade elevated access ?

any help would be greatly appreciated. thank you

Tweepy works with both v1.1 API and v2 API.

You can use v2 API with Essential Client — tweepy 4.10.1 documentation

But you need Elevated access to use v1.1 API API — tweepy 4.10.1 documentation

thanks @IgorBrigadir for explanation…
now i try using v2 API with Essential tweepy.Client… while waiting approval from twitter for elevated access application.
it is still pending for 2 days

But, using tweepy.client i face a different problem with code 401 Unauthorized.
could someone has suggestion to fix that problem ?

i really appreciate your help with this.

best regard

Hey, I’m facing somewhat the same problem but my account does have an elevated access. I’m trying to upload images to my twitter account using a Python bot, and it displays the same error.
Do I have to turn on either of the authentication settings? Because the rest of my dashboard looks pretty well, and I think that might be the problem. Or has Twitter changed the access rules to the API for posting images?

Regards,

Alright, I figured it out. It was indeed the authentication setting. For the new updated settings, initially, your account has a read only access even if you have an elevated access. So you need to turn either of the OAuth 2.0a or OAuth 1.0a on and fill in the required fields to get your app ready for read and write operations. That solved my problem.

Hola soy el cantante chiko la makina conocido en europa y latino america quien puede ayudarme con la verificación de mi cuenta de twitter estoy verificado en instagram en facebook spotify en youtube en google en tik tok pueden ayudarme a verificar twitter para empezar a promocionar mi musica por twitter ads gracias

I have the same problem. I have Elevated Access approval, but I’m getting a 403 forbidden error saying
image1225×258 20.7 KB

I have enabled all the things I can see:
image607×848 25.5 KB slow_movies:

I have the same problem. I have Elevated Access approval, but I’m getting a 403 forbidden error saying

Is this app added to a project? The App settings themselves look correct.

No, it wasn’t a Production App, it was still in Development. That might have been it.

In the end, I fixed it by making a new app in the same project. I made that one as “production” from the start.

Thanks for the advice.