使用 Tweepy v2 访问 Twitter 时间线时出现 Forbidden 403 错误

问题描述 投票:0回答:1

我在尝试使用 Tweepy v2 访问我的 Twitter 时间线时遇到“Forbidden 403”错误。以下是我的代码的相关部分:

import tweepy
import keys_test as keys

# ... (other imports and variable assignments)

client = tweepy.Client(bearer_token, api_key, api_secret, access_token, access_token_secret)
auth = tweepy.OAuth1UserHandler(keys.api_key, keys.api_secret, keys.access_token, keys.access_token_secret)
api = tweepy.API(auth)
status = client.get_home_timeline()

for stat in status:
    print(stat)

我收到的错误消息如下:

Forbidden: 403 Forbidden
When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the developer portal.

我已尝试使用 Tweepy 中的客户端和 api 对象,但仍然遇到此问题。我的密钥和令牌是从单独的文件正确导入的。我还仔细检查了我的 Twitter 开发者应用程序是否已正确配置并附加到项目。

有人可以提供有关如何解决使用 Tweepy v2 访问 Twitter 时间线时出现的“Forbidden 403”错误的指导吗?任何帮助将不胜感激。谢谢!

python twitter oauth tweepy
1个回答
0
投票

您需要付费才能访问 api 端点,请检查此答案

https://stackoverflow.com/a/76520660/18812499

© www.soinside.com 2019 - 2024. All rights reserved.