在 Endpoint 之后的 Twitter API v2 上获取 403 Forbidden

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

您好,我已经购买了 Twitter API v2 的基本计划。我在邮递员上分叉了 Twitter 公共工作区,以测试我的项目所需的不同端点。当我尝试

https://api.twitter.com/2/users/by/username/:username 

它成功了,我得到了用户 ID。然而,当我尝试其他终点时,例如:

https://api.twitter.com/2/users/:id/followers

https://api.twitter.com/2/users/:id/following

我收到以下回复:


{
    "client_id": "27723471",
    "detail": "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.",
    "registration_url": "https://developer.twitter.com/en/docs/projects/overview",
    "title": "Client Forbidden",
    "required_enrollment": "Appropriate Level of API Access",
    "reason": "client-not-enrolled",
    "type": "https://api.twitter.com/2/problems/client-forbidden"
}

我已经在项目中创建了我的应用程序,您可以在下图中看到设置:

我在更改应用程序设置之前和之后重新生成了 api 密钥、api 密钥、承载令牌、访问令牌和访问令牌密钥。我已经删除并重新创建了它,对于每个排列,我已经删除并重新创建了该项目大约 10 次,但错误似乎并没有消失。我在 tweepy 中编写了一些代码,使用 :id/following 端点,不出所料,它给出了相同的错误。

Tweepy 代码:

# Set up Tweepy API client
client = tweepy.Client(bearer_token, api_key, api_secret,
                       access_token, access_token_secret, wait_on_rate_limit=True)

# Initialize tables for TinyDB
predefined_tweets_table = db.table('predefined_tweets')
liked_tweets_table = db.table('liked_tweets')
commented_tweets_table = db.table('commented_tweets')

MY_HANDLE = "xxxxxx"
MY_ID = xxxxxxx


def get_following():
    paginator = tweepy.Paginator(
    client.get_users_following,            # The method you want to use
    MY_ID,
    max_results=10,                       # How many tweets per page
)
    for page in paginator:
        print("\npage",page)
        print("\npage.data",page.data)                       # The tweets are here
        print("\npage.meta",page.meta)                       # The count etc. are here
        print("\npage.includes",page.includes)                   # The includes are here
        time.sleep(15)

我已经浪费了 4 个小时,并且截止日期非常严格,任何帮助将不胜感激。 问候

python postman tweepy twitter-api-v2
1个回答
0
投票

基于此处的信息https://twittercommunity.com/t/get-2-users-id-following-is-now-broken/197526

https://api.twitter.com/2/users/:id/followers https://api.twitter.com/2/users/:id/follwoing

上述这些端点已于 6 月 26 日被 Twitter 删除,讽刺的是,您仍然可以在官方文档中看到它们!

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