بنقرة واحدة
wechat-article-publisher
Publish Markdown/HTML articles to WeChat Official Account (微信公众号) drafts via API
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Publish Markdown/HTML articles to WeChat Official Account (微信公众号) drafts via API
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | wechat-article-publisher |
| description | Publish Markdown/HTML articles to WeChat Official Account (微信公众号) drafts via API |
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' |
| articleType | string | No | 'news' (default) or 'newspic' |
| 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.