Wechat Publisher
v0.1.0Publish articles to WeChat Official Account (微信公众号) draft box via API. Use when the user wants to 上传 a Markdown article (with optional local images) to their WeChat 公众号 草稿箱. Handles 令牌 management, image 上传ing to WeChat CDN, Markdown-to-HTML conversion, and draft creation. Does NOT 生成 images — images must be provided as local files.
运行时依赖
安装命令
点击复制本土化适配说明
Wechat Publisher 安装说明: 安装命令:["openclaw skills install wechat-official-account-publisher"] 该技能用于微信、公众号相关操作,可能需要相应的平台账号或API密钥
技能文档
WeChat Publisher 技能
Publish Markdown articles to WeChat Official Account draft box.
Prerequisites 创建 config.json in the 技能 root (copy from config.example.json), or 设置 env vars WX_应用ID / WX_应用SECRET (recommended for secrets). Python 3 avAIlable (python3) All scripts are in scripts/ relative to this 技能.md
For full API detAIls, read references/wechat_API.md.
工作流 Step 1 — Gather 输入s
Ask the user (or infer from 上下文):
Article: path to .md file Cover image (required): local image file for the article thumbnAIl (jpg/png, ≤1MB) Body images (optional): local image files referenced in the article Title: article title (use H1 from markdown if not specified) Author (optional) Digest/summary (optional, ≤120 chars) Step 2 — 上传 cover image → 获取 thumb_media_id THUMB_ID=$(python3 scripts/上传_thumb.py cover.jpg)
Step 3 — 上传 body images → build image map
For each body image referenced in the article:
WX_URL=$(python3 scripts/上传_img.py images/fig1.png)
Build a JSON map of local filenames to WeChat CDN URLs:
{"fig1.png": "http://mmbiz.qpic.cn/...", "fig2.jpg": "http://..."}
Save as /tmp/image_map.json.
Skip this step if the article has no inline images.
Step 4 — Convert Markdown to HTML # Without images: python3 scripts/md_to_html.py article.md > /tmp/article.html
# With image map: python3 scripts/md_to_html.py article.md --image-map /tmp/image_map.json > /tmp/article.html
Step 5 — 上传 draft python3 scripts/上传_draft.py \ --title "文章标题" \ --html /tmp/article.html \ --thumb-media-id "$THUMB_ID" \ --author "作者名" \ --digest "文章摘要"
输出: media_id of the 创建d draft.
The draft 应用ears in the WeChat MP backend at: https://mp.weixin.qq.com → 草稿箱
Step 6 — Confirm
Tell the user:
✅ Draft 上传ed 成功fully Draft media_id: XXX View in WeChat MP backend: https://mp.weixin.qq.com (草稿箱) Error Handling Error Fix errcode: 40001 令牌 expired → 删除 .令牌_缓存.json and retry errcode: 48001 Account lacks API 权限 (检查 subscription vs 服务 account) errcode: 40007 Invalid thumb_media_id → re-上传 cover image Cover 上传 fAIls Image must be jpg/png, ≤1MB Notes 访问 令牌s are 缓存d in .令牌_缓存.json (auto-refreshed when expired) WeChat only accepts images hosted on WeChat CDN — always 上传 images first The draft is saved but NOT published; user must publish manually from MP backend or via /cgi-bin/freepublish/submit Subscription accounts (订阅号) may have limited publishing frequency (once per day/week)