代码之家  ›  专栏  ›  技术社区  ›  Duke

在Twitter API v2上获取403 Forbidden following Endpoint

  •  0
  • Duke  · 技术社区  · 1 年前

    大家好,我已经购买了Twitter API v2的基本计划。我在poster上分叉了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"
    }
    

    我在一个项目中创建了我的应用程序,您可以在下图中看到设置: enter image description here

    在更改应用程序设置前后,我重新生成了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个小时,而且在一个非常严格的截止日期,任何帮助都将不胜感激。 当做

    0 回复  |  直到 1 年前
        1
  •  0
  •   Duke    1 年前

    根据这里的信息 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日被推特删除,具有讽刺意味的是,你仍然可以在官方文档中看到它们!