wechat-article-publisher by iamzifei/wechat-article-publisher-skill
npx skills add https://github.com/iamzifei/wechat-article-publisher-skill --skill wechat-article-publisher通过 API 将 Markdown 或 HTML 内容发布到微信公众号草稿箱,支持自动格式转换。
位于 ~/.claude/skills/wechat-article-publisher/scripts/:
用于列出账号和发布文章的微信 API 客户端:
# 列出已授权账号
python wechat_api.py list-accounts
# 从 markdown 文件发布
python wechat_api.py publish --appid <wechat_appid> --markdown /path/to/article.md
# 从 HTML 文件发布(保留格式)
python wechat_api.py publish --appid <wechat_appid> --html /path/to/article.html
# 使用自定义选项发布
python wechat_api.py publish --appid <appid> --markdown /path/to/article.md --type newspic
解析 Markdown 并提取结构化数据(可选,用于高级用途):
python parse_markdown.py <markdown_file> [--output json|html]
策略:"API 优先发布"
与基于浏览器的发布方式不同,此技能使用直接 API 调用实现可靠、快速的发布。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
支持的文件格式:
.md 文件 → 解析为 Markdown,由微信 API 转换.html 文件 → 作为 HTML 发送,格式保留在任何操作之前,验证 API 密钥是否可用:
# 检查 .env 文件是否存在并包含 WECHAT_API_KEY
cat .env | grep WECHAT_API_KEY
如果未设置,提醒用户:
.env.example 到 .envWECHAT_API_KEY 值获取已授权的微信账号列表:
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py list-accounts
输出示例:
{
"success": true,
"data": {
"accounts": [
{
"name": "我的公众号",
"wechatAppid": "wx1234567890",
"username": "gh_abc123",
"type": "subscription",
"verified": true,
"status": "active"
}
],
"total": 1
}
}
重要提示:
wechatAppid 用于发布对于 Markdown 文件:
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py publish \
--appid <wechatAppid> \
--markdown /path/to/article.md
对于 HTML 文件(保留格式):
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py publish \
--appid <wechatAppid> \
--html /path/to/article.html
对于 小绿书(图文模式):
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py publish \
--appid <wechatAppid> \
--markdown /path/to/article.md \
--type newspic
成功响应:
{
"success": true,
"data": {
"publicationId": "uuid-here",
"materialId": "uuid-here",
"mediaId": "wechat-media-id",
"status": "published",
"message": "文章已成功发布到公众号草稿箱"
}
}
成功发布后:
所有 API 请求都需要 X-API-Key 请求头:
X-API-Key: WECHAT_API_KEY
POST https://wx.limyai.com/api/openapi/wechat-accounts
POST https://wx.limyai.com/api/openapi/wechat-publish
参数:
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| wechatAppid | string | 是 | 微信 AppID |
| title | string | 是 | 文章标题(最多 64 字符) |
| content | string | 是 | 文章内容(Markdown/HTML) |
| summary | string | 否 | 文章摘要(最多 120 字符) |
| coverImage | string | 否 | 封面图片 URL |
| author | string | 否 | 作者名称 |
| contentFormat | string | 否 | 'markdown'(默认)或 'html' |
| articleType | string | 否 | 'news'(默认)或 'newspic' |
| 代码 | 描述 |
|---|---|
| API_KEY_MISSING | 未提供 API 密钥 |
| API_KEY_INVALID | API 密钥无效 |
| ACCOUNT_NOT_FOUND | 账号未找到或未授权 |
| ACCOUNT_TOKEN_EXPIRED | 账号授权已过期 |
| INVALID_PARAMETER | 参数无效 |
| WECHAT_API_ERROR | 微信 API 调用失败 |
| INTERNAL_ERROR | 服务器错误 |
...)<title> 或 <h1> → 文章标题<img> 标签 → 图片自动上传到微信<p> → 自动提取为摘要HTML 标题提取优先级:
<title> 标签内容<h1> 标签内容HTML 内容提取:
<body>,使用 body 内容<html>、<head>、<!DOCTYPE> 并使用剩余内容用户:"把 ~/articles/ai-tools.md 发布到微信公众号"
# 步骤 1: 验证 API 密钥
cat .env | grep WECHAT_API_KEY
# 步骤 2: 列出账号
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py list-accounts
# 步骤 3: 发布(假设只有一个账号,appid 为 wx1234567890)
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py publish \
--appid wx1234567890 \
--markdown ~/articles/ai-tools.md
# 步骤 4: 报告
# "文章已成功发布到公众号草稿箱!请登录微信公众平台预览并发布。"
用户:"把这个HTML文章发布到公众号:~/articles/newsletter.html"
# 步骤 1: 验证 API 密钥
cat .env | grep WECHAT_API_KEY
# 步骤 2: 列出账号
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py list-accounts
# 步骤 3: 发布 HTML(自动检测格式)
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py publish \
--appid wx1234567890 \
--html ~/articles/newsletter.html
# 步骤 4: 报告
# "文章已成功发布到公众号草稿箱!HTML格式已保留。请登录微信公众平台预览并发布。"
Error: WECHAT_API_KEY environment variable not set.
解决方案:要求用户使用 API 密钥设置 .env 文件。
Error: ACCOUNT_NOT_FOUND - 公众号不存在或未授权
解决方案:要求用户在 wx.limyai.com 上授权其账号。
Error: ACCOUNT_TOKEN_EXPIRED - 公众号授权已过期
解决方案:要求用户在 wx.limyai.com 上重新授权。
Error: WECHAT_API_ERROR - 微信接口调用失败
解决方案:可能是临时问题,重试或检查微信服务状态。
最小工作流程(1 条命令):
- list-accounts → 获取 appid → publish → 完成
完整工作流程(带验证):
1. 检查 .env → 列出账号 → 与用户确认
2. 使用选项发布 → 报告结果
答:在 wx.limyai.com 注册并授权您的微信账号以获取 API 密钥。
答:可以,使用 list-accounts 查看所有已授权账号,然后指定目标 --appid。
答:确保图片是可访问的 URL。本地图片会自动上传,但如果路径不正确可能会失败。
答:微信限制标题为 64 字符。脚本将使用 H1 的前 64 个字符。
答:news 是标准文章格式;newspic(小绿书)是以图片为中心且文本有限的格式。
每周安装量
1.0K
仓库
GitHub 星标数
93
首次出现
Jan 20, 2026
安全审计
安装于
opencode980
gemini-cli957
codex953
cursor950
github-copilot933
kimi-cli917
Publish Markdown or HTML content to WeChat Official Account drafts via API, with automatic format conversion.
Located in ~/.claude/skills/wechat-article-publisher/scripts/:
WeChat API client for listing accounts and publishing articles:
# List authorized accounts
python wechat_api.py list-accounts
# Publish from markdown file
python wechat_api.py publish --appid <wechat_appid> --markdown /path/to/article.md
# Publish from HTML file (preserves formatting)
python wechat_api.py publish --appid <wechat_appid> --html /path/to/article.html
# Publish with custom options
python wechat_api.py publish --appid <appid> --markdown /path/to/article.md --type newspic
Parse Markdown and extract structured data (optional, for advanced use):
python parse_markdown.py <markdown_file> [--output json|html]
Strategy: "API-First Publishing"
Unlike browser-based publishing, this skill uses direct API calls for reliable, fast publishing.
Supported File Formats:
.md files → Parsed as Markdown, converted by WeChat API.html files → Sent as HTML, formatting preservedBefore any operation, verify the API key is available:
# Check if .env file exists and contains WECHAT_API_KEY
cat .env | grep WECHAT_API_KEY
If not set, remind user to:
.env.example to .envWECHAT_API_KEY valueGet the list of authorized WeChat accounts:
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py list-accounts
Output example:
{
"success": true,
"data": {
"accounts": [
{
"name": "我的公众号",
"wechatAppid": "wx1234567890",
"username": "gh_abc123",
"type": "subscription",
"verified": true,
"status": "active"
}
],
"total": 1
}
}
Important :
wechatAppid for publishingFor Markdown files:
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py publish \
--appid <wechatAppid> \
--markdown /path/to/article.md
For HTML files (preserves formatting):
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py publish \
--appid <wechatAppid> \
--html /path/to/article.html
For 小绿书 (image-text mode):
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py publish \
--appid <wechatAppid> \
--markdown /path/to/article.md \
--type newspic
Success response:
{
"success": true,
"data": {
"publicationId": "uuid-here",
"materialId": "uuid-here",
"mediaId": "wechat-media-id",
"status": "published",
"message": "文章已成功发布到公众号草稿箱"
}
}
After successful publishing:
All API requests require the X-API-Key header:
X-API-Key: WECHAT_API_KEY
POST https://wx.limyai.com/api/openapi/wechat-accounts
POST https://wx.limyai.com/api/openapi/wechat-publish
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| wechatAppid | string | Yes | WeChat AppID |
| title | string | Yes | Article title (max 64 chars) |
| content | string | Yes | Article content (Markdown/HTML) |
| summary | string | No | Article summary (max 120 chars) |
| coverImage | string | No | Cover image URL |
| author | string | No | Author name |
| contentFormat | string | No | 'markdown' (default) or 'html' |
| Code | Description |
|---|---|
| API_KEY_MISSING | API key not provided |
| API_KEY_INVALID | API key invalid |
| ACCOUNT_NOT_FOUND | Account not found or unauthorized |
| ACCOUNT_TOKEN_EXPIRED | Account authorization expired |
| INVALID_PARAMETER | Invalid parameter |
| WECHAT_API_ERROR | WeChat API call failed |
| INTERNAL_ERROR | Server error |
...)<title> or <h1> → Article title<img> tags → Images auto-uploaded to WeChat<p> → Auto-extracted as summaryHTML Title Extraction Priority:
<title> tag content<h1> tag contentHTML Content Extraction:
<body> exists, uses body content<html>, <head>, <!DOCTYPE> and uses remaining contentUser: "把 ~/articles/ai-tools.md 发布到微信公众号"
# Step 1: Verify API key
cat .env | grep WECHAT_API_KEY
# Step 2: List accounts
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py list-accounts
# Step 3: Publish (assuming single account with appid wx1234567890)
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py publish \
--appid wx1234567890 \
--markdown ~/articles/ai-tools.md
# Step 4: Report
# "文章已成功发布到公众号草稿箱!请登录微信公众平台预览并发布。"
User: "把这个HTML文章发布到公众号:~/articles/newsletter.html"
# Step 1: Verify API key
cat .env | grep WECHAT_API_KEY
# Step 2: List accounts
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py list-accounts
# Step 3: Publish HTML (auto-detects format)
python ~/.claude/skills/wechat-article-publisher/scripts/wechat_api.py publish \
--appid wx1234567890 \
--html ~/articles/newsletter.html
# Step 4: Report
# "文章已成功发布到公众号草稿箱!HTML格式已保留。请登录微信公众平台预览并发布。"
Error: WECHAT_API_KEY environment variable not set.
Solution : Ask user to set up .env file with their API key.
Error: ACCOUNT_NOT_FOUND - 公众号不存在或未授权
Solution : Ask user to authorize their account on wx.limyai.com.
Error: ACCOUNT_TOKEN_EXPIRED - 公众号授权已过期
Solution : Ask user to re-authorize on wx.limyai.com.
Error: WECHAT_API_ERROR - 微信接口调用失败
Solution : May be temporary issue, retry or check WeChat service status.
Minimal workflow (1 command):
- list-accounts → get appid → publish → done
Full workflow (with verification):
1. Check .env → list accounts → confirm with user
2. Publish with options → report result
A: Register and authorize your WeChat account at wx.limyai.com to get your API key.
A: Yes, use list-accounts to see all authorized accounts, then specify the target --appid.
A: Ensure images are accessible URLs. Local images are auto-uploaded but may fail if path is incorrect.
A: WeChat limits titles to 64 characters. The script will use the first 64 chars of H1.
A: news is standard article format; newspic (小绿书) is image-focused with limited text.
Weekly Installs
1.0K
Repository
GitHub Stars
93
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubWarnSocketPassSnykPass
Installed on
opencode980
gemini-cli957
codex953
cursor950
github-copilot933
kimi-cli917
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
App Store Connect 元数据自动化本地化工具 - asc-localize-metadata 使用指南
931 周安装
Python后端开发指南:FastAPI、SQLAlchemy异步与Upstash缓存最佳实践
932 周安装
NotebookLM Python库:自动化访问Google NotebookLM,实现AI内容创作与文档处理
934 周安装
Base44 CLI 工具 - 创建和管理 Base44 应用项目 | 命令行开发工具
936 周安装
SwiftUI 开发模式指南:状态管理、视图组合与导航最佳实践
937 周安装
Ant Design 最佳实践指南:React 组件库使用决策、主题配置与性能优化
937 周安装
| articleType |
| string |
| No |
| 'news' (default) or 'newspic' |