Install
openclaw skills install @tobewin/wechat-publisheropenclaw skills install @tobewin/wechat-publisher纯 Python stdlib,零外部依赖。覆盖微信官方文档全部发布相关 API。
⚠️ 数据外发提醒:本文稿内容、媒体文件、账号标识符(AppID)将被发送至微信官方 API 服务器(api.weixin.qq.com)。请勿在自动化环境中处理敏感/机密内容。
⚠️ 操作不可逆提醒:所有删除操作(draft delete / published delete / material delete / comment delete / comment delreply)及 publish 发布均不可撤销。执行时需加
--confirm确认。
export WECHAT_APP_ID='your_app_id'
export WECHAT_APP_SECRET='your_app_secret'
export WECHAT_AUTHOR='作者名(可选)'
⚠️ 2025 年 7 月起,个人主体账号、企业主体未认证账号将被回收发布接口权限。
操作不可逆的删除/发布命令需加 --confirm 确认执行。
公众号发布工具 v1.0.9
======================== 草稿管理 ========================
draft create <json> 创建草稿(JSON 支持多图文)
draft get <media_id> 获取草稿详情
draft update <media_id> <json> [--index N]
draft count 草稿数量
draft list [--offset 0] [--count 20]
draft delete <media_id> [--confirm]
======================== 发布管理 ========================
publish <media_id> [--confirm] 提交发布(返回 publish_id + msg_data_id)
publish status <publish_id> 查询发布状态
======================== 已发布管理 ======================
published list [--offset 0] [--count 20] [--no-content 1]
published delete <article_id> [--confirm]
published getarticle <article_id> 获取已发布图文详情
======================== 素材管理 ========================
material add <file> [--type image|thumb|video] [--title T] [--intro I]
material get <media_id> [--out <file>]
material delete <media_id> [--confirm]
material list [--type image|video|voice|news] [--offset 0] [--count 20]
material update_news <media_id> <json> [--index 0]
======================== 图片上传 ========================
upload <image_path> 上传图片用于正文(返回永久 URL)
======================== 数据统计 ========================
stats summary <begin> <end>
stats total <begin> <end>
stats read <begin> <end>
stats readhour <begin> <end>
stats share <begin> <end>
stats sharehour <begin> <end>
stats userread <begin> <end>
stats userreadhour <begin> <end>
======================== 评论管理 ========================
comment list <msg_data_id> [--index 0] [--begin 0] [--count 50] [--type 0]
comment mark <msg_data_id> --comment_id <id>
comment unmark <msg_data_id> --comment_id <id>
comment delete <msg_data_id> --comment_id <id> [--confirm]
comment reply <msg_data_id> --comment_id <id> --content <text>
comment delreply <msg_data_id> --comment_id <id> [--confirm]
======================== 其他 ============================
render <file> [--style standard|business|minimal|tech|academic|warm]
test 测试连接
# 创建包含 2 篇图文消息的草稿
cat > articles.json << 'EOF'
[
{
"title": "第一篇",
"author": "作者",
"content": "<p>正文 HTML</p>",
"digest": "摘要",
"thumb_media_id": "MEDIA_ID",
"need_open_comment": 1
},
{
"title": "第二篇",
"author": "作者",
"content": "<p>第二篇正文</p>",
"thumb_media_id": "MEDIA_ID"
}
]
EOF
python3 scripts/publish_wechat.py draft create articles.json
内容准备
↓
render 命令 → 公众号排版 HTML
↓
upload 命令 → 上传正文图片(media/uploadimg)→ 图片 URL
↓
material add --type image → 上传封面图(永久素材)→ media_id
↓
draft create <json> → 创建草稿 → media_id
↓
publish <media_id> → 提交发布 → publish_id + msg_data_id
↓
publish status <publish_id> → 确认发布成功
↓
published getarticle <article_id> → 查看已发布详情
↓
comment list <msg_data_id> → 管理评论