wechat-draft-publisher
Original:🇨🇳 Chinese
Translated
6 scripts
Automatically publish HTML articles to WeChat Official Account draft box, supporting cover image upload, title, author and metadata management. Use this when the user says "push to WeChat", "publish to official account draft", "upload to draft box" or mentions WeChat article publishing.
10installs
Added on
NPX Install
npx skill4agent add bnd-1/wechat_article_skills wechat-draft-publisherTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →WeChat Official Account Draft Publisher
Automatically publish HTML-formatted articles to WeChat Official Account draft box, supporting cover image upload, title, author, abstract and other metadata management.
⚡ Quick Start
Simplest usage:
bash
python publisher.py --title "Article Title" --content article.htmlFull parameters:
bash
python publisher.py \
--title "Title" \
--content article.html \
--author "Author Name" \
--cover cover.png \
--digest "Article Abstract"Default values:
- Author:
YanG - Cover image:
cover.png
📋 Execution Steps
Complete workflow for publishing articles to WeChat draft box:
-
Locate HTML file
- Prioritize looking for (formatter output)
*_formatted.html - Fall back to the latest file
.html
- Prioritize looking for
-
Extract article title
- Extract from HTML comment:
<!-- Title: xxx --> - Extract from file name
- Ask user for input
- Extract from HTML comment:
-
Check cover image
- Look for
cover.png - Warn but continue publishing if missing
- Look for
-
Call publishing scriptbash
python publisher.py --title "xxx" --content xxx.html --cover xxx.png -
Verify results
- Confirm draft creation success
- Obtain draft media_id
-
Notify user
- Provide WeChat backend link
- Explain next steps
🔧 Configuration Requirements
First-time Usage
The tool will guide you through configuration on first run:
-
Obtain WeChat Official Account Credentials
- Visit https://mp.weixin.qq.com
- Go to Settings → Basic Configuration
- Copy AppID and AppSecret
-
Run the publisherbash
python publisher.py --title "Test" --content test.html -
Add server IP to whitelist (if required)
Configuration File
Location:
~/.wechat-publisher/config.jsonFormat:
json
{
"appid": "wx1234567890abcdef",
"appsecret": "your_secret_here"
}✨ Core Features
- ✅ Automatic access_token caching (valid for 7200 seconds)
- ✅ Cover image upload and management
- ✅ Automatic HTML content optimization (WeChat-adapted)
- ✅ Automatic field length truncation (title/author/abstract)
- ✅ Error handling and retry mechanism
- ✅ Chinese error prompts and solutions
- ✅ Interactive mode and command-line mode
🛠️ Workflow Integration
Collaborate with other skills:
Complete workflow:
- → Generate article (
wechat-tech-writer+xxx_article.md)cover.png - → Format HTML (
wechat-article-formatter)xxx_formatted.html - → Publish to WeChat draft box (this skill)
wechat-draft-publisher
Automatic detection mechanism:
- Automatically find files
*_formatted.html - Automatically find cover images
cover.png - Automatically identify content images
🚨 FAQ
Error: IP not in whitelist
Symptom:
Solution:
invalid ip not in whitelist- Log in to WeChat Official Account backend
- Go to Settings → Basic Configuration
- Add server IP to whitelist
Error: AppSecret error
Symptom:
Solution:
AppSecret error- Check configuration file:
~/.wechat-publisher/config.json - Verify AppID starts with "wx" (18 characters)
- Confirm AppSecret is correct
Error: Title/author exceeds limit
Symptom:
Solution:
title/author size out of limit- The tool will automatically truncate (title: 32 bytes, author: 20 bytes)
- To adjust, modify
publisher.py
📁 File Structure
wechat-draft-publisher/
├── SKILL.md # This file
├── publisher.py # Core publishing script
├── scripts/ # Utility scripts
│ ├── fix-wechat-style.py # HTML optimizer
│ ├── optimize-html.py # HTML compression tool
│ ├── publish-workflow.sh # Complete workflow
│ ├── install.sh # Installation assistant
│ └── test.sh # Test script
├── examples/ # Example files
│ ├── config.json.example # Configuration example
│ └── example.html # HTML example
└── README.md # Detailed English documentation💡 Usage Examples
Example 1: Standard publishing
bash
python publisher.py \
--title "VSCode Renaming Incident" \
--content article.htmlExample 2: Full metadata
bash
python publisher.py \
--title "Technical Article" \
--content article.html \
--author "YanG" \
--cover images/cover.png \
--digest "This is an article about..."Example 3: Interactive mode
bash
python publisher.py --interactive📱 Post-Publishing Actions
After successful publishing:
- Log in to WeChat Official Account backend
- Go to "Draft Box"
- Preview the effect
- Publish after confirmation
Notes:
- ⚠️ Drafts are saved in WeChat backend and will not be published immediately
- ⚠️ You can edit drafts in the draft box before publishing
- ⚠️ Cover images will be displayed during preview
🔗 Related Documents
- Detailed Documentation: README.md (English)
- Installation Guide: scripts/install.sh
- HTML Processing: scripts/fix-wechat-style.py