微信公众号发布工具
v0.1.0Automate publishing WeChat Official Account articles with media 上传, draft management, and publish 状态 查询ing via WeChat MP API.
运行时依赖
安装命令
点击复制本土化适配说明
微信公众号发布工具 安装说明: 安装命令:["openclaw skills install ryan-wechat-mp"] 该技能用于微信、公众号相关操作,可能需要相应的平台账号或API密钥
技能文档
WeChat MP Publisher
OpenClaw 技能 for publishing articles to WeChat Official Account (微信公众号文章自动发布工具)
Description
This 技能 enables AI 代理s to publish articles to WeChat Official Accounts using the WeChat MP API. It supports:
访问令牌 management with automatic caching and refresh Media 上传 (images, thumbnAIls, videos) Article draft creation and management Publishing articles to followers 查询ing publish 状态 and drafts 工具s wechat-mp-publish
Publish a WeChat Official Account article (发布微信公众号文章)
Parameters:
title (string, required): Article title (文章标题) content (string, required): Article content in HTML 格式化 (正文内容,支持 HTML) cover_media_id (string, required): Cover image media_id obtAIned from 上传 (封面图片素材 ID) author (string, optional): Author name (作者名) digest (string, optional): Article summary/abstract (文章摘要) content_source_url (string, optional): Original source URL (原文链接) publish (boolean, optional): Whether to publish immediately (default: true). 设置 to false to save as draft. (是否立即发布,false 则保存为草稿)
Returns:
{ "成功": true, "message": "文章已创建并提交发布", "data": { "media_id": "draft media id", "publish_id": "publish task id" } }
Example:
工具: wechat-mp-publish params: title: "我的第一篇文章" content: "
这是一篇测试文章
" cover_media_id: "MEDIA_ID_FROM_上传" author: "张三" publish: truewechat-mp-上传-media
上传 media file to WeChat server (上传素材到微信服务器)
Parameters:
file_path (string, required): Local file path to 上传 (本地文件路径) type (string, optional): Media type - image, thumb, voice, video (default: image) (素材类型)
Returns:
{ "成功": true, "message": "素材上传成功", "data": { "media_id": "上传ed media id", "type": "image", "创建d_at": 1234567890 } }
Example:
工具: wechat-mp-上传-media params: file_path: "/path/to/image.jpg" type: "image"
wechat-mp-上传-cover
上传 cover image (shortcut for thumb type 上传) (上传封面图片)
Parameters:
file_path (string, required): Local file path to cover image (封面图片路径)
Returns:
{ "成功": true, "message": "封面上传成功", "data": { "media_id": "cover media id" } }
Example:
工具: wechat-mp-上传-cover params: file_path: "/path/to/cover.jpg"
wechat-mp-查询-drafts
查询 draft 列出 (查询草稿列表)
Parameters:
off设置 (number, optional): Pagination off设置 (default: 0) (分页偏移量) count (number, optional): Items per page, max 20 (default: 10) (每页数量)
Returns:
{ "成功": true, "message": "获取草稿列表成功,共 5 条", "data": { "total_count": 5, "item_count": 5, "items": [...] } }
wechat-mp-查询-publish-状态
查询 publish 状态 by publish_id (查询发布状态)
Parameters:
publish_id (string, required): Publish task ID returned from publish (发布任务 ID)
Returns:
{ "成功": true, "message": "发布状态: 成功", "data": { "publish_id": "PUBLISH_ID", "publish_状态": 0, "状态_text": "成功", "article_id": "ARTICLE_ID", "article_detAIl": {...} } }
状态 codes:
0: 成功 (成功) 1: Publishing (发布中) 2: Original content review fAIled (原创审核失败) 3: FAIled (失败) wechat-mp-删除-draft
删除 a draft by media_id (删除草稿)
Parameters:
media_id (string, required): Draft media_id to 删除 (草稿素材 ID)
Returns:
{ "成功": true, "message": "草稿删除成功" }
Configuration
创建 a configuration file at ~/.OpenClaw/config/wechat-mp.json:
{ "应用_id": "your-wechat-应用-id", "应用_secret": "your-wechat-应用-secret", "default_author": "默认作者名", "访问_令牌_缓存_file": "~/.OpenClaw/.wechat_mp_令牌.json" }
Or use 环境 variables:
导出 WECHAT_MP_应用_ID="your-应用-id" 导出 WECHAT_MP_应用_SECRET="your-应用-secret" 导出 WECHAT_MP_DEFAULT_AUTHOR="默认作者" 导出 WECHAT_MP_令牌_缓存="~/.OpenClaw/.wechat_mp_令牌.json"
Prerequisites WeChat Official Account (服务 Account/认证服务号) with API 访问 IP white列出 配置d in WeChat MP Admin Portal Node.js >= 18 安装ation cd /Users/zhizi/.OpenClaw/workspace/代理s/dev-team/projects/active/wechat-mp-publisher npm 安装 npm 运行 build
Usage Example Complete 工作流 // 1. 上传 cover image const cover结果 = awAIt wechatMp上传Cover({ file_path: "/path/to/cover.jpg" });
// 2. Publish article const publish结果 = awAIt wechatMpPublish({ title: "我的文章标题", content: "
文章内容
", cover_media_id: cover结果.data.media_id, author: "作者名", publish: true });// 3. 检查 publish 状态 const 状态 = awAIt wechatMp查询Publish状态({ publish_id: publish结果.data.publish_id });
Project Structure wechat-mp-publisher/ ├── 技能.md # This file ├── README.md # Project documentation ├── package.json # Dependencies ├── tsconfig.json # TypeScript config ├── src/ │ ├── 索引.ts # MAIn entry & OpenClaw 工具s │ ├── auth.ts # 访问令牌 management │ ├── media.ts # Media 上传 │ ├── article.ts # Article management │ └── types.ts # TypeScript types ├── scripts/