用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/aaione/everything-claude-code-zh --skill x-api命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Kubernetes 工作负载模式、资源管理、RBAC、probes、autoscaling、ConfigMap/Secret 处理,以及面向生产级部署的 kubectl 调试。
完成任何非平凡任务后使用。智能体按 5 个维度自评输出——准确性、完整性、清晰度、可执行性、简洁性——每项都给出具体证据。生成结构化 1-5 评分卡和具体改进建议。
在 competitive-platform-analysis 产出分层竞品集合后使用。按九个加权维度(定位、声音、视觉工艺、offer packaging、证据、enterprise-readiness、thought leadership、定价、客户 strategic tension)为每个竞品评分,使用明确 1–5 rubrics 和 tension-plot。位于 competitive-report-structure 之前。
基于 SOC 职业分类
正在显示 SKILL.md
| name | x-api |
| description | X/Twitter API 集成,用于发布推文、线程、阅读时间线、搜索和分析。涵盖 OAuth 认证模式、速率限制和平台原生内容发布。当用户想要以编程方式与 X 交互时使用。 |
与 X(Twitter)的编程交互,用于发布、阅读、搜索和分析。
最适合:重度读取操作、搜索、公共数据。
# 环境设置
export X_BEARER_TOKEN="your-bearer-token"
import os
import requests
bearer = os.environ["X_BEARER_TOKEN"]
headers = {"Authorization": f"Bearer {bearer}"}
# 搜索最近的推文
resp = requests.get(
"https://api.x.com/2/tweets/search/recent",
headers=headers,
params={"query": "claude code", "max_results": 10}
)
tweets = resp.json()
需要用于:发布推文、管理账户、DM 和任何写入流。
# 环境设置 — 使用前获取
export X_CONSUMER_KEY="your-consumer-key"
export X_CONSUMER_SECRET="your-consumer-secret"
export X_ACCESS_TOKEN="your-access-token"
export X_ACCESS_TOKEN_SECRET="your-access-token-secret"
旧设置中的遗留别名如 X_API_KEY、X_API_SECRET 和 X_ACCESS_SECRET 可能存在。在记录或连接新流时,优先使用 X_CONSUMER_* 和 X_ACCESS_TOKEN_SECRET 名称。
import os
from requests_oauthlib import OAuth1Session
oauth = OAuth1Session(
os.environ["X_CONSUMER_KEY"],
client_secret=os.environ["X_CONSUMER_SECRET"],
resource_owner_key=os.environ["X_ACCESS_TOKEN"],
resource_owner_secret=os.environ["X_ACCESS_TOKEN_SECRET"],
)
resp = oauth.post(
"https://api.x.com/2/tweets",
json={"text": "来自 Claude Code 的你好"}
)
resp.raise_for_status()
tweet_id = resp.json()["data"]["id"]
def post_thread(oauth, tweets: list[str]) -> list[str]:
ids = []
reply_to = None
for text in tweets:
payload = {"text": text}
if reply_to:
payload["reply"] = {"in_reply_to_tweet_id": reply_to}
resp = oauth.post("https://api.x.com/2/tweets", json=payload)
tweet_id = resp.json()["data"]["id"]
ids.append(tweet_id)
reply_to = tweet_id
return ids
resp = requests.get(
f"https://api.x.com/2/users/{user_id}/tweets",
headers=headers,
params={
"max_results": 10,
"tweet.fields": "created_at,public_metrics",
}
)
resp = requests.get(
"https://api.x.com/2/tweets/search/recent",
headers=headers,
params={
"query": "from:affaanmustafa -is:retweet",
"max_results": 10,
"tweet.fields": "public_metrics,created_at",
}
)
resp = requests.get(
"https://api.x.com/2/tweets/search/recent",
headers=headers,
params={
"query": "from:affaanmustafa -is:retweet -is:reply",
"max_results": 25,
"tweet.fields": "created_at,public_metrics",
}
)
voice_samples = resp.json()
resp = requests.get(
"https://api.x.com/2/users/by/username/affaanmustafa",
headers=headers,
params={"user.fields": "public_metrics,description,created_at"}
)
# 媒体上传使用 v1.1 端点
# 步骤 1:上传媒体
media_resp = oauth.post(
"https://upload.twitter.com/1.1/media/upload.json",
files={"media": open("image.png", "rb")}
)
media_id = media_resp.json()["media_id_string"]
# 步骤 2:带媒体发布
resp = oauth.post(
"https://api.x.com/2/tweets",
json={"text": "看看这个", "media": {"media_ids": [media_id]}}
)
X API 速率限制因端点、认证方法和账户层级而异,并且它们随时间变化。始终:
x-rate-limit-remaining 和 x-rate-limit-reset 头import time
remaining = int(resp.headers.get("x-rate-limit-remaining", 0))
if remaining < 5:
reset = int(resp.headers.get("x-rate-limit-reset", 0))
wait = max(0, reset - int(time.time()))
print(f"接近速率限制。在 {wait}s 后重置")
resp = oauth.post("https://api.x.com/2/tweets", json={"text": content})
if resp.status_code == 201:
return resp.json()["data"]["id"]
elif resp.status_code == 429:
reset = int(resp.headers["x-rate-limit-reset"])
raise Exception(f"速率限制。在 {reset} 重置")
elif resp.status_code == 403:
raise Exception(f"禁止:{resp.json().get('detail', '检查权限')}")
else:
raise Exception(f"X API 错误 {resp.status_code}:{resp.text}")
.env 文件。.env 文件。 添加到 .gitignore。使用 brand-voice 加上 content-engine 生成平台原生内容,然后通过 X API 发布:
语音配置文件content-engine 以 X 原生格式生成内容brand-voice — 从真实 X 和站点/来源材料构建可重用的语音配置文件content-engine — 为 X 生成平台原生内容crosspost — 跨 X、LinkedIn 和其他平台分发内容connections-optimizer — 在起草网络驱动的外联之前重新组织 X 图表