How to Get X API Keys
如何获取 X (Twitter) API 密钥
To post to X through this app, you need 4 API credentials from the X Developer Portal. Follow the steps below to obtain them.
要通过本应用发布推文,你需要从 X 开发者平台获取 4 个 API 密钥。请按以下步骤操作。
Create an X Developer Account
注册 X 开发者账号
- Visit developer.x.com and sign in with your X account.
访问 developer.x.com 并用你的 X 账号登录。 - If you haven't already, apply for a Developer account. The free tier is sufficient.
如果还没有开发者账号,申请一个即可。免费套餐就够用了。 - Complete the application form describing your use case (e.g., “scheduling and posting tweets for my personal account”).
填写申请表,描述你的用途(如"为个人账号定时发推")。
Create a Project & App
创建项目和应用
- In the Developer Portal, go to Projects & Apps.
在开发者面板中,进入 Projects & Apps 页面。 - Click + Create Project. Give it a name (e.g., “Post Scheduler”).
点击 + Create Project,取个名字(如"Post Scheduler")。 - Under the project, create an App. Name it anything you like.
在项目下创建一个 App,名称随意。
Set App Permissions
设置应用权限
重要:必须在生成 Token 之前设置权限。如果之后更改权限,需要重新生成所有 Token。
- Go to your App's Settings tab.
进入 App 的 Settings 选项卡。 - Under User authentication settings, click Set up.
在 User authentication settings 下点击 Set up。 - Set App permissions to Read and Write.
将 App permissions 设为 Read and Write。 - Set type to Web App, fill in a callback URL (any valid URL is fine, e.g., your app URL).
类型选 Web App,回调 URL 填任意有效 URL(如你的应用地址)。 - Save the settings.
保存设置。
Generate API Key & Secret
生成 API Key 和 Secret
- Go to your App's Keys and tokens tab.
进入 App 的 Keys and tokens 选项卡。 - Under Consumer Keys, click Regenerate (or view if already generated).
在 Consumer Keys 下点击 Regenerate(或 View)。 - Copy the API Key and API Key Secret. Save them securely.
复制 API Key 和 API Key Secret,妥善保存。
Example format:
API Key: aB1cD2eF3gH4iJ5kL6
API Secret: mN7oP8qR9sT0uV1wX2yZ3...
Generate Access Token & Secret
生成 Access Token 和 Secret
- On the same Keys and tokens page, scroll to Authentication Tokens.
在同一个 Keys and tokens 页面,向下滚动到 Authentication Tokens 部分。 - Click Generate under Access Token and Secret.
点击 Access Token and Secret 下的 Generate。 - Make sure it says “Created with Read and Write permissions”.
确认显示"Created with Read and Write permissions"。 - Copy the Access Token and Access Token Secret. Save them securely.
复制 Access Token 和 Access Token Secret,妥善保存。
Add Credentials to xPilot
将密钥添加到 X 推创
- Sign in to xPilot and go to the Settings page.
登录 X 推创 并进入设置页面。 - In the Add X Account section, fill in:
在"Add X Account"部分填写:- API Key → Consumer API Key
- API Secret → Consumer API Key Secret
- Access Token → Access Token
- Access Token Secret → Access Token Secret
- Click Add Account. The app will verify your credentials and show your X username.
点击 Add Account。应用会验证凭证并显示你的 X 用户名。
Troubleshooting / 常见问题
“403 Forbidden” when posting
Your app permissions are likely set to “Read only”. Change to Read and Write in app settings, then regenerate both your Access Token and Secret.
你的应用权限可能是"只读"。请改为"读写",然后重新生成 Access Token 和 Secret。
“401 Unauthorized”
Double-check that all 4 keys are correct and haven't been regenerated since you copied them.
请确认 4 个密钥都正确,且复制后没有被重新生成过。
“429 Too Many Requests”
You've hit the X API rate limit. The free tier allows ~17 tweets per 24 hours. Wait and try again later.
触发了 X API 速率限制。免费套餐每 24 小时约可发 17 条推文,稍后再试。