Install
openclaw skills install wechat-official-account-publisherPublish articles to WeChat Official Account (微信公众号) draft box via API. Use when the user wants to upload a Markdown article (with optional local images) to their WeChat 公众号 草稿箱. Handles token management, image uploading to WeChat CDN, Markdown-to-HTML conversion, and draft creation. Does NOT generate images — images must be provided as local files.
openclaw skills install wechat-official-account-publisherPublish Markdown articles to WeChat Official Account draft box.
config.json in the skill root (copy from config.example.json), or set env vars WX_APPID / WX_APPSECRET (recommended for secrets).python3)scripts/ relative to this SKILL.mdFor full API details, read references/wechat_api.md.
Ask the user (or infer from context):
.md fileTHUMB_ID=$(python3 scripts/upload_thumb.py cover.jpg)
For each body image referenced in the article:
WX_URL=$(python3 scripts/upload_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.
# 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
python3 scripts/upload_draft.py \
--title "文章标题" \
--html /tmp/article.html \
--thumb-media-id "$THUMB_ID" \
--author "作者名" \
--digest "文章摘要"
Output: media_id of the created draft.
The draft appears in the WeChat MP backend at: https://mp.weixin.qq.com → 草稿箱
Tell the user:
XXX| Error | Fix |
|---|---|
errcode: 40001 | Token expired → delete .token_cache.json and retry |
errcode: 48001 | Account lacks API permission (check subscription vs service account) |
errcode: 40007 | Invalid thumb_media_id → re-upload cover image |
| Cover upload fails | Image must be jpg/png, ≤1MB |
.token_cache.json (auto-refreshed when expired)/cgi-bin/freepublish/submit