关于 x-cli
X CLI 是用于调用 X API 的命令行工具,可管理帖子、账户和社交活动。它提供发布、搜索、媒体、列表、书签及分析命令。
主要功能
- 01发布、回复和删除推文
- 02查看时间线、提及和点赞
- 03按查询条件搜索帖子
- 04上传媒体并附加到帖子
- 05管理用户、列表和书签
- 06查看分析数据并导出推文
适用场景
- 01发布帖子和串文更新
- 02查找符合主题或账户条件的帖子
- 03查看关注者增长并导出推文数据
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ dl-alexandre/ skills --skill x-cli安装后在 Claude Code 中输入/x-cli确认已加载。
详细介绍
X CLI
使用 x 命令行工具与 X API 交互。
前提条件
x --version
export X_API_KEY='your-api-key'
export X_API_SECRET='your-api-secret'
export X_ACCESS_TOKEN='your-access-token'
export X_ACCESS_SECRET='your-access-secret'
x auth status
身份验证
- 来自 X Developer Portal 的 API 凭据
- 环境变量:
X_API_KEY、X_API_SECRET、X_ACCESS_TOKEN、X_ACCESS_SECRET - 或者:使用
x auth login进行 OAuth 流程
推文
创建和管理
x tweet "Hello from the CLI!"
x tweet "Check this out" --media ./image.png
x tweet "Thread part 1" --thread
x tweet "Thread part 2" --reply-to TWEET_ID
x delete TWEET_ID --confirm
阅读时间线
x timeline --limit 50
x timeline --user USERNAME --limit 20
x mentions --limit 20
x likes --user USERNAME
搜索
x search --query "#javascript" --limit 100
x search --query "from:elonmusk" --recent
x search --query "AI filter:images" --limit 50
媒体
x upload ./image.jpg --alt "Description"
x upload ./video.mp4 --media-type video
x tweet "Video content" --media MEDIA_ID
用户
x user get USERNAME
x user followers USERNAME --limit 100
x user following USERNAME --limit 100
x follow USERNAME
x unfollow USERNAME --confirm
列表和书签
x lists list
x lists get LIST_ID --tweets
x lists create "Tech News" --description "Technology updates"
x bookmarks --limit 50
分析
x analytics tweets --days 30
x analytics followers --growth
x export tweets --start 2024-01-01 --format csv
Agent 最佳实践
- 速率限制:遵守 X API 的速率限制(使用
x limits查看) - 推文长度:最多 280 个字符(X Premium 用户最多 4,000 个)
- 媒体格式:支持 JPG、PNG、GIF、MP4
- 线程安全:使用
--thread标志创建多条推文组成的线程
评论
支持 Markdown