ZJU-REAL/Easel / skills/builtin/skill-wechat-publisher
skill-wechat-publisher
Verified微信公众号文章自动创作与发布工具。给定参考文章、文字或文档,自动搜索整理全网相关信息、生成图文并茂的公众号文章,并发布到微信公众号草稿箱。特别强调反 AI 检测写作。 触发场景(沾边就用):用户提到"公众号 / 微信文章 / 推文 / 公号 / 发文 / mp / 草稿箱 / 群发",或要求把话题/文档/笔记写成公众号文章并发布到微信。
references/api_reference.md
View on GitHub# 微信公众号 API 接口参考
本文档列出了发布文章流程中涉及的所有微信API接口,方便快速查阅。
## 1. 获取 Access Token
- **URL**: `https://api.weixin.qq.com/cgi-bin/token`
- **方法**: GET
- **参数**:
- `grant_type`: 固定值 `client_credential`
- `appid`: 公众号的AppID
- `secret`: 公众号的AppSecret
- **返回值**:
```json
{"access_token": "ACCESS_TOKEN", "expires_in": 7200}
```
- **注意**: token有效期2小时,需要缓存和自动刷新;IP白名单必须配置
## 2. 上传永久素材(封面图)
- **URL**: `https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type=image`
- **方法**: POST (multipart/form-data)
- **参数**: `media` - 图片文件
- **限制**: 图片大小不超过10MB,支持 jpg/png/gif/bmp
- **返回值**:
```json
{"media_id": "MEDIA_ID", "url": "URL"}
```
- **用途**: 获取封面图的 `media_id`,用于创建草稿时的 `thumb_media_id`
## 3. 上传正文图片
- **URL**: `https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN`
- **方法**: POST (multipart/form-data)
- **参数**: `media` - 图片文件
- **限制**: 图片大小不超过10MB
- **返回值**:
```json
{"url": "https://mmbiz.qpic.cn/..."}
```
- **用途**: 获取微信CDN图片URL,嵌入文章HTML正文中。此接口上传的图片不占用永久素材名额。
## 4. 新建草稿
- **URL**: `https://api.weixin.qq.com/cgi-bin/draft/add?access_token=ACCESS_TOKEN`
- **方法**: POST (application/json)
- **请求体**:
```json
{
"articles": [
{
"title": "文章标题",
"author": "作者",
"digest": "摘要(不超过120字)",
"content": "HTML正文内容",
"content_source_url": "原文链接",
"thumb_media_id": "封面图的media_id",
"need_open_comment": 1,
"only_fans_can_comment": 0
}
]
}
```
- **返回值**:
```json
{"media_id": "DRAFT_MEDIA_ID"}
```
- **注意**:
- `content` 中的图片必须使用微信CDN的URL(通过uploadimg接口获取)
- 编码必须使用 `ensure_ascii=False` 避免中文乱码
- 单次最多8篇文章
## 5. 发布草稿(可选)
- **URL**: `https://api.weixin.qq.com/cgi-bin/freepublish/submit?access_token=ACCESS_TOKEN`
- **方法**: POST
- **请求体**:
```json
{"media_id": "DRAFT_MEDIA_ID"}
```
- **返回值**: 发布任务ID
- **注意**: 建议在公众平台手动确认发布,避免误操作
## 常见错误码
| 错误码 | 说明 | 解决方法 |
|--------|------|----------|
| 40001 | access_token无效 | 重新获取token |
| 40002 | 不合法的凭证类型 | 检查AppID/AppSecret |
| 40004 | 不合法的媒体文件类型 | 检查图片格式 |
| 40009 | 图片大小超限 | 压缩到10MB以内 |
| 40014 | 不合法的access_token | 刷新token |
| 45009 | 接口调用超限 | 降低调用频率 |
| 48001 | 接口未授权 | 检查公众号权限 |
| 40164 | IP不在白名单中 | 在公众平台添加IP白名单 |
## API调用频率限制
- access_token获取:每日2000次
- 素材上传:每日100次
- 草稿操作:每日100次
- 建议合理缓存token,避免频繁调用
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |