Skip to main content
POST
代表已认证的源用户发布推文。该端点代理官方 X v2 POST /2/tweets 端点,并通过位于 https://api.aisa.one/apis/v1/twitter/post_twitter 的 AIsa 网关进行路由。 一个端点涵盖所有变体:

纯文本

{ "text": "Hello, World!" }

回复

设置 reply.in_reply_to_tweet_id。

引用推文

设置 quote_tweet_id。

附带投票

设置 poll.options + poll.duration_minutes。

附带媒体

设置 media.media_ids(1–4 个 ID)。

编辑推文

设置 edit_options.previous_post_id(须在 X 的编辑时限内)。

前置条件

  • 一个 AIsa API 密钥(每个请求均使用 Bearer token)。
  • 对源用户账户进行一次性 OAuth 授权。通过调用 POST /apis/v1/twitter/auth_twitter 关联你的 X 账户——AIsa 会将会话与 API 密钥关联存储,并在每次写入调用时自动使用该会话。
  • X 会话必须拥有 tweet.read、tweet.write、users.read。

互斥字段

单个请求中最多只能出现以下字段中的一个:
  • media
  • poll
  • quote_tweet_id
  • card_uri
如果设置了多个字段,X 将拒绝请求(400 invalid-request)。

响应

成功时,端点返回 201 Created:
返回的 text 反映 X 实际存储的内容(例如缩短后的 URL)。可使用 data.id 在后续调用中引用该推文(回复、引用、点赞、编辑、删除)。

编辑推文

传入 edit_options.previous_post_id 可编辑现有推文,而不是创建新推文。编辑受 X 的编辑时限和编辑次数限制;如果已超过时限或编辑配额已用尽,端点将返回 409 conflict。

回复设置

使用 reply_settings 限制可回复的用户: 省略该字段则使用默认设置(所有人)。

常见 4xx 原因

  • 400 invalid-request——设置了两个互斥字段、文本过长、投票持续时间无效等。
  • 403 client-forbidden——OAuth 会话缺少 tweet.write scope。请通过 auth_twitter 重新关联。
  • 404 resource-not-found——引用的 in_reply_to_tweet_id、quote_tweet_id 或 previous_post_id 不存在,或对源用户不可见。
  • 409 conflict——内容重复,或在允许的时限之外进行编辑。
完整列表请参阅错误代码,各层级上限请参阅速率限制。

相关内容

关联 X 账户

启动此端点所需的 OAuth 流程。

关注用户

使用同一 OAuth 会话的另一个写入端点。

Twitter 自动驾驶技能

封装完整 Twitter 功能面的 Agent 技能。

授权

Authorization
string
header
必填

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

请求体

content
默认值:""
必填
Maximum string length: 280
in_reply_to_tweet_id
默认值:""
必填
Maximum string length: 64
media_ids
必填
aisa_api_key
string
Maximum string length: 64
card_uri
string
Maximum string length: 256
media
object
media_files
string
poll
object
quote_tweet_id
string
Maximum string length: 64
reply
object
reply_settings
string
Maximum string length: 32
text
any

Alternate spelling for /content; ignored when the canonical value is present and nonempty.

响应

Successful ApiResponse serialized by the owning service.

code
integer
必填
msg
string
必填
data
object | null

The owning service explicitly declares an optional dictionary of arbitrary values; nested Twitter result fields are opaque.