Open4

Xのポスト投稿の流れ

BuzoBuzo

画像添付した時
POST https://upload.twitter.com/i/media/upload.json?command=INIT&total_bytes=5450&media_type=image%2Fpng&media_category=tweet_imageが叩かれている。
返却値は

{
    "media_id": 1769157170313256960,
    "media_id_string": "1769157170313256960",
    "expires_after_secs": 86399,
    "media_key": "3_1769157170313256960"
}

その次に
POST https://upload.twitter.com/i/media/upload.json?command=APPEND&media_id=1769157170313256960&segment_index=0が叩かれている
返却値は無し。ステータスは204。

その次は
POST https://upload.twitter.com/i/media/upload.json?command=FINALIZE&media_id=1769157170313256960&original_md5=b25a531289ef2aa8099107b29b6469f5
返却値は無しでステータスは201 Created

投稿画面のプレビュー画像はblobになっている。
blob:https://twitter.com/f627c7c0-7a04-49ae-b1c0-3c83904c8b91

BuzoBuzo

それぞれのレスポンスタイム

  • POST https://upload.twitter.com/i/media/upload.json?command=INIT&total_bytes=5450&media_type=image%2Fpng&media_category=tweet_image

  • POST https://upload.twitter.com/i/media/upload.json?command=APPEND&media_id=1769157170313256960&segment_index=0

  • POST https://upload.twitter.com/i/media/upload.json?command=FINALIZE&media_id=1769157170313256960&original_md5=b25a531289ef2aa8099107b29b6469f5

BuzoBuzo

「ポストする」をクリック
POST https://twitter.com/i/api/graphql/sgqau0P5BUJPMU_lgjpd_w/CreateTweetが叩かれる。
Payload

{
  "variables": {
    "tweet_text": "テスト\n",
    "dark_request": false,
    "media": {
      "media_entities": [
        {
          "media_id": "1769157170313256960",
          "tagged_users": []
        }
      ],
      "possibly_sensitive": false
    },
    "semantic_annotation_ids": []
  },
  "features": {
    "c9s_tweet_anatomy_moderator_badge_enabled": true,
    "tweetypie_unmention_optimization_enabled": true,
    "responsive_web_edit_tweet_api_enabled": true,
    "graphql_is_translatable_rweb_tweet_is_translatable_enabled": true,
    "view_counts_everywhere_api_enabled": true,
    "longform_notetweets_consumption_enabled": true,
    "responsive_web_twitter_article_tweet_consumption_enabled": true,
    "tweet_awards_web_tipping_enabled": false,
    "longform_notetweets_rich_text_read_enabled": true,
    "longform_notetweets_inline_media_enabled": true,
    "rweb_video_timestamps_enabled": true,
    "responsive_web_graphql_exclude_directive_enabled": true,
    "verified_phone_label_enabled": false,
    "freedom_of_speech_not_reach_fetch_enabled": true,
    "standardized_nudges_misinfo": true,
    "tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled": true,
    "responsive_web_graphql_skip_user_profile_image_extensions_enabled": false,
    "responsive_web_graphql_timeline_navigation_enabled": true,
    "responsive_web_enhance_cards_enabled": false
  },
  "queryId": "sgqau0P5BUJPMU_lgjpd_w"
}

レスポンス

{
  "data": {
    "create_tweet": {
      "tweet_results": {
        "result": {
          "rest_id": "1769161396875665689",
          "core": {
            "user_results": {
              "result": {
                "__typename": "User",
              // 省略
            }
          },
          "unmention_data": {},
          "edit_control": {
            "edit_tweet_ids": [
              "1769161396875665689"
            ],
            "editable_until_msecs": "1710639521000",
            "is_edit_eligible": true,
            "edits_remaining": "5"
          },
          "views": {
            "state": "Enabled"
          },
          "source": "<a href=\"https://mobile.twitter.com\" rel=\"nofollow\">Twitter Web App</a>",
          "legacy": {
            "bookmark_count": 0,
            "bookmarked": false,
            "created_at": "Sun Mar 17 00:38:41 +0000 2024",
            "conversation_id_str": "1769161396875665689",
            "display_text_range": [
              0,
              3
            ],
            "entities": {
              "hashtags": [],
              "media": [
                {
                  "display_url": "pic.twitter.com/DG74jwuFeg",
                  "expanded_url": "https://twitter.com/{ユーザー名}/status/1769161396875665689/photo/1",
                  "id_str": "1769157170313256960",
                  "indices": [
                    4,
                    27
                  ],
                  "media_url_https": "https://pbs.twimg.com/media/GI1PErBbYAA4bss.png",
                  "type": "photo",
                  "url": "https://t.co/DG74jwuFeg",
                  "features": {},
                  "sizes": {
                    "large": {
                      "h": 150,
                      "w": 150,
                      "resize": "fit"
                    },
                    "medium": {
                      "h": 150,
                      "w": 150,
                      "resize": "fit"
                    },
                    "small": {
                      "h": 150,
                      "w": 150,
                      "resize": "fit"
                    },
                    "thumb": {
                      "h": 150,
                      "w": 150,
                      "resize": "crop"
                    }
                  },
                  "original_info": {
                    "height": 150,
                    "width": 150
                  }
                }
              ],
              "symbols": [],
              "timestamps": [],
              "urls": [],
              "user_mentions": []
            },
            "extended_entities": {
              "media": [
                {
                  "display_url": "pic.twitter.com/DG74jwuFeg",
                  "expanded_url": "https://twitter.com/{ユーザー名}/status/1769161396875665689/photo/1",
                  "id_str": "1769157170313256960",
                  "indices": [
                    4,
                    27
                  ],
                  "media_key": "3_1769157170313256960",
                  "media_url_https": "https://pbs.twimg.com/media/GI1PErBbYAA4bss.png",
                  "type": "photo",
                  "url": "https://t.co/DG74jwuFeg",
                  "features": {},
                  "sizes": {
                    "large": {
                      "h": 150,
                      "w": 150,
                      "resize": "fit"
                    },
                    "medium": {
                      "h": 150,
                      "w": 150,
                      "resize": "fit"
                    },
                    "small": {
                      "h": 150,
                      "w": 150,
                      "resize": "fit"
                    },
                    "thumb": {
                      "h": 150,
                      "w": 150,
                      "resize": "crop"
                    }
                  },
                  "original_info": {
                    "height": 150,
                    "width": 150
                  },
                  "allow_download_status": {
                    "allow_download": true
                  }
                }
              ]
            },
            "favorite_count": 0,
            "favorited": false,
            "full_text": "テスト https://t.co/DG74jwuFeg",
            "is_quote_status": false,
            "lang": "ja",
            "possibly_sensitive": false,
            "possibly_sensitive_editable": true,
            "quote_count": 0,
            "reply_count": 0,
            "retweet_count": 0,
            "retweeted": false,
            "user_id_str": "ユーザーID",
            "id_str": "1769161396875665689"
          },
          "unmention_info": {}
        }
      }
    }
  }
}
BuzoBuzo

レスポンスタイム

  • POST https://twitter.com/i/api/graphql/sgqau0P5BUJPMU_lgjpd_w/CreateTweet