You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过推文JSON数据获取指定推文的转发者screename列表

解答:获取推文转发者的Screen Name(Username)

Great questions! Let's break this down using the X (formerly Twitter) API, since that's the official way to pull this data programmatically from tweet JSON responses.

1. 列出指定推文的所有转发者Screen Name

To get the screen names (now officially called usernames by X) of users who retweeted a specific tweet, you'll use the X API v2 endpoint GET /2/tweets/:id/retweeted_by. Here's how it works:

  • Authentication: You'll need a valid Bearer Token (for app-only access) or OAuth 1.0a credentials (for user-specific access), with the read:users and read:tweets permissions enabled.
  • Endpoint Usage: Replace :id with the target tweet's unique ID. The endpoint returns a JSON response where the data array contains objects for each retweeting user. Each object includes the username field—that's the screen name you're looking for.

Example JSON response snippet:

{
  "data": [
    {
      "id": "123456789",
      "name": "Jane Doe",
      "username": "janedoe123" // This is the screen name
    },
    {
      "id": "987654321",
      "name": "John Smith",
      "username": "johnsmith_456"
    }
  ],
  "meta": {
    "result_count": 2,
    "next_token": "abc123" // Use this for pagination if there are more retweeters
  }
}
  • Pagination: If the tweet has more than 100 retweeters (the default max_results limit), use the next_token from the meta object in subsequent requests to fetch the next batch of users.

2. 推文发布后获取转发者的名称

Once your tweet is live, you have two reliable ways to capture retweeters' screen names:

Option 1: Poll the endpoint periodically

If real-time updates aren't a priority, simply call the same GET /2/tweets/:id/retweeted_by endpoint at regular intervals (e.g., every 5 minutes). Compare the returned usernames with your existing list to identify new retweeters.

Option 2: Use Webhooks for real-time alerts

For instant notifications when someone retweets your tweet, set up a webhook via the X Account Activity API. Configure it to listen for retweet_events linked to your tweet. When a retweet occurs, the webhook will receive a payload containing the retweeting user's details, including their screen name.

Example webhook payload snippet (v1.1 format, which includes the legacy screen_name field):

{
  "tweet_create_events": [
    {
      "retweeted_status": {
        "id": "YOUR_TWEET_ID"
      },
      "user": {
        "id": "RETWEETER_ID",
        "name": "Retweeter Name",
        "screen_name": "retweeter_screenname" // Matches the screen name you see on X
      }
    }
  ]
}

In API v2, the field is renamed to username, but it represents the same screen name value you're targeting.

内容的提问来源于stack exchange,提问作者mamesaye

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:53:52