开始使用 Direct Message 管理端点
构建私信查找请求的步骤
第一步:从工具或库入手
步骤二:为你的请求进行认证
- 创建一个 Token Name,例如 “DM lookup”。
- 确认 Grant Type 设置为 Authorization Code (with PKCE)。
- 设置你的 Callback URL。需将 Callback URL 更新为与 v2 Dev Portal 中与你的应用关联的 Callback URL 完全一致。本示例所用的 X 应用,其 Callback URL 设置为 - https://www.example.com(注意必须完全匹配,https://example.com 将无法使用)。
- 确认 Auth URL 设置为 https://x.com/i/oauth2/authorize
- 确认 Access Token URL 设置为 https://api.x.com/2/oauth2/token。 Client ID - 从开发者门户复制并粘贴 OAuth 2.0 Client ID Client Secret - 仅当你使用的应用类型为机密客户端时才需要此项。如需, 从开发者门户复制并粘贴 OAuth 2.0 Client Secret。
- 确认 Scope 设置为 dm.read dm.write tweet.read users.read。
- 确认 State 设置为 “state”。
- 确认 Client Authentication 设置为 Send as Basic Auth header。
- 点击 “Get New Access Token”,在 “Sign-in with X” 流程中点击 “Authorize app”。
- 点击 “Proceed” 按钮,然后点击 “Use Token” 以生成令牌。
- 点击 “Save” 按钮保存这些配置。
步骤三:检索私信会话事件
| Key | Value |
dm_conversation_id | 1228393702244134912 |
- 默认的 Direct Message 对象字段:id、text 和 event_type。
- 额外的 Direct Message 对象字段:dm_conversation_id、created_at、sender_id、attachments、participant_ids、referenced_tweets
| Key | Value |
| dm_event.fields | dm_conversation_id,created_at,sender_id,attachments,participant_ids,referenced_tweets |