Install
openclaw skills install wechat-mp-editorCreate, edit, and manage WeChat Official Account (公众号/服务号) articles via the official WeChat API. Handles access token management, image uploads, draft CRUD, publishing, and HTML content formatting with WeChat-compatible CSS. Trigger when the user asks to: write/edit WeChat articles, create/publish drafts, format WeChat push notifications, generate article HTML, or manage WeChat MP drafts through the API.
openclaw skills install wechat-mp-editorFull workflow: credentials → access token → image upload → draft creation → publishing.
One fixed template — visual branding consistent. Only content (text, date, banner) changes.
Priority: Write from ideas queue first.
File: skills/wechat-mp-editor/ideas-queue.json
Status: pending / writing / done / archived
FIFO by default, or ask user. Empty queue → scan ClawHub/GitHub Trending → propose 3-5 topics.
Read before writing:
references/templates.md — 唯一排版规范references/review-checklist.md — 发布前检查清单<section> 和 <p> 加 word-break:normal;white-space:normalpadding:36px 20px 40px;text-align:center;巡梦人(#bbb)+ 从一颗星星开始,温暖整个宇宙(#aaa)color:#d4a5740.1 实体确认 — 同名产品/公司先确认目标实体。
0.2 信息收集 + 事实校验 — 两轮:广度收集 → 逐句核查论断性句子。
0.3 方向确认 — 输出 3-5 句 What/Why/How。用户确认后再写。如果中途文章结构发生重大变更(改比喻方向、替换方案、增加大段内容),重新输出方向确认,不可直接下笔。
credentials/wechat-official.json:
{"name":"巡梦人","appId":"wx...","appSecret":"...","type":"wechat_mp"}
GET https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=***
Returns access_token, valid 2h.
Body images (/cgi-bin/media/uploadimg):
curl -s -F "media=@image.png" "https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=***"
Returns {"url": "http://mmbiz.qpic.cn/..."}.
Cover image (/cgi-bin/material/add_material):
curl -s -F "media=@cover.png" "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=***&type=image"
Returns {"media_id": "..."}. 封面图必须 1:1 方形,否则报 53402。
Use references/templates.md. Fill in variables at marked locations.
requests 库的 json= 参数默认 ensure_ascii=True,会将中文转为 \uXXXX 转义码,微信编辑器显示为乱码。
禁止使用 requests.post(url, json=payload)。
必须使用 以下两种方式之一:
方式 A(推荐):写文件 + curl
import json
with open('/tmp/draft.json', 'w', encoding='utf-8') as f:
json.dump(payload, f, ensure_ascii=False) # ensure_ascii=False 是必须的
curl -s -X POST "https://api.weixin.qq.com/cgi-bin/draft/add?access_token=***" \
-H "Content-Type: application/json; charset=utf-8" \
--data-binary @/tmp/draft.json
方式 B(仅没有 curl 时):
import json, requests
requests.post(url, data=json.dumps(payload, ensure_ascii=False).encode('utf-8'),
headers={"Content-Type": "application/json"})
第一次创建用 draft/add。后续所有修改用 draft/update,不要重复 add 制造新草稿。
# 更新已有草稿
payload["media_id"] = "已有DRAFT_ID"
requests.post(".../draft/update?...", data=..., headers=...)
resp = requests.post(".../draft/get?...", json={"media_id": draft_id})
content = resp.json()["news_item"][0]["content"]
# 必须验证的内容
checks = {
"title": "预期的标题",
"已设置的中文摘要": True,
"\\u": False, # 必须为 False — 不得有转义码
"[\u4e00-\u9fff]": True, # 必须有真实中文字符
}
POST /cgi-bin/freepublish/submit with {"media_id": "DRAFT_ID"}.
<style> / <script>文章用图通过 即梦 AI 由用户生成。本 skill 仅负责:
不自行写提示词格式,不维护提示词经验池。
□ 移动端:每段 ≤35 中文字符,特征卡 ≤20 字符
□ 移动端:特征卡间距正确(首 N-1 张 12px,末张 0px)
□ 移动端:连续正文不超过 3 段,需插入图片/分隔线/特征卡
□ 格式:分隔线全篇 padding 统一为 12px 20px
□ 格式:footer 颜色 品牌名 #bbb / 标语 #aaa
□ 格式:section 开闭数一致(<section> 数 = </section> 数)
□ 封面:media_id 已更换(非上次文章的残留 ID)
□ 编码:提交后回读验证 content 无 \uXXXX 转义
□ 编码:提交后回读验证 content 有真实中文字符
□ 摘要:digest 已设置且前 54 字不是 HTML 标签
references/templates.md — 排版规范references/review-checklist.md — 检查清单scripts/generate_images.py — 图片生成