SuperAPI AI Directory

wechat-draft-publisher

Marketing & growth

View repository

Updated 10-16 09:35

About this skill

WeChat Official Account Draft Publisher

Automatically publish HTML-format articles to the WeChat Official Account draft box, supporting metadata management such as cover image upload, title, author, and summary.

⚡ Quick Start

Simplest usage:

python publisher.py --title "文章标题" --content article.html

Full parameters:

python publisher.py \
  --title "标题" \
  --content article.html \
  --author "作者名" \
  --cover cover.png \
  --digest "文章摘要"

Default values:

  • Author:YanG
  • Cover image:cover.png

📋 Execution Steps

Complete process for publishing an article to the WeChat draft box:

  1. Find the HTML file

    • Prioritize finding *_formatted.html(formatter output)
    • Fall back to the latest .html file
  2. Extract the article title

    • Extract from HTML comments:<!-- Title: xxx -->
    • Extract from the file name
    • Ask the user
  3. Check the cover image

    • Find cover.png
    • If missing, warn but continue publishing
  4. Call the publishing script

    python publisher.py --title "xxx" --content xxx.html --cover xxx.png
    
  5. Verify the result

    • Confirm the draft was created successfully
    • Get the draft media_id
  6. Notify the user

    • Provide the WeChat backend link
    • Explain the next steps

🔧 Configuration Requirements

First-time use

The tool will guide configuration on first run:

  1. Obtain WeChat Official Account credentials

  2. Run the publisher

    python publisher.py --title "测试" --content test.html
    
  3. Add the server IP to the whitelist(if needed)

Configuration file

Location: ~/.wechat-publisher/config.json

Format:

{
  "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 (adapted for WeChat)
  • ✅ Automatic field length truncation (title/author/summary)
  • ✅ Error handling and retry mechanism
  • ✅ Chinese error messages and solutions
  • ✅ Interactive mode and command-line mode

🛠️ Workflow Integration

Works in coordination with other skills:

Complete workflow:

  1. wechat-tech-writer → Generate article (xxx_article.md + cover.png)
  2. wechat-article-formatter → Format HTML (xxx_formatted.html)
  3. wechat-draft-publisher → Publish to WeChat draft box (this skill)

Automatic detection mechanism:

  • Automatically find *_formatted.html files
  • Automatically find cover.png cover images
  • Automatically identify content images

🚨 Common Issues

Error: IP not in whitelist

Symptoms: invalid ip not in whitelist Solution:

  1. Log in to the WeChat Official Account backend
  2. Go to Settings → Basic Configuration
  3. Add the server IP to the whitelist

Error: Incorrect AppSecret

Symptoms: AppSecret error Solution:

  • Check the configuration file:~/.wechat-publisher/config.json
  • Verify that the AppID starts with "wx" (18 characters)
  • Confirm that the AppSecret is correct

Error: Title/author exceeds the limit

Symptoms: title/author size out of limit Solution:

  • The tool will automatically truncate (title: 32 bytes, author: 20 bytes)
  • To adjust, modify publisher.py

📁 File structure

wechat-draft-publisher/
├── SKILL.md                # 本文件
├── publisher.py            # 核心发布脚本
├── scripts/                # 工具脚本
│   ├── fix-wechat-style.py # HTML 优化器
│   ├── optimize-html.py    # HTML 压缩工具
│   ├── publish-workflow.sh # 完整工作流
│   ├── install.sh          # 安装助手
│   └── test.sh             # 测试脚本
├── examples/               # 示例文件
│   ├── config.json.example # 配置示例
│   └── example.html        # HTML 示例
└── README.md               # 详细英文文档

💡 Usage examples

Example 1: Standard publishing

python publisher.py \
  --title "VSCode 更名事件" \
  --content article.html

Example 2: Complete metadata

python publisher.py \
  --title "技术文章" \
  --content article.html \
  --author "YanG" \
  --cover images/cover.png \
  --digest "这是一篇关于..."

Example 3: Interactive mode

python publisher.py --interactive

📱 Post-publishing actions

After successful publishing:

  1. Log in to the WeChat Official Account backend
  2. Go to "Drafts"
  3. Preview the result
  4. Publish after confirmation

Notes:

  • ⚠️ The draft is saved in the WeChat backend and will not be published immediately
  • ⚠️ You can edit it in the drafts box before publishing
  • ⚠️ The cover image will be displayed during preview

🔗 Related documentation