SuperAPI AI Directory

good-mp-post

General & other

View repository

Updated 10-15 22:18

About this skill

Good Official Account Publishing

Task Objective

Complete the full process of creating, laying out, and publishing WeChat Official Account articles with AI assistance.

Capabilities: Article creation, image generation and upload, draft creation, article publishing

Trigger: The user needs to create or publish a WeChat Official Account article

Usage Modes

Mode 1: Web UI (Recommended)

Visual interface supporting article management, online editing, and publishing:

# 安装依赖
pip install -r requirements.txt
Start the service (default port 8000)

uvicorn app.main:app --reload

Access in browser

http://localhost:8000


**功能:**
- 文章CRUD操作(创建、查看、编辑、删除)
- Markdown内容编辑
- 数据库持久化(SQLite)
- 直接发布到微信公众号
- 发布历史记录

### 模式2:脚本 (命令行)
适合自动化场景,与Web UI共享数据库:

```bash
# 上传图片
python scripts/upload_media.py /path/to/image.jpg thumb

# 创建草稿
python scripts/create_draft.py --title "标题" --content "内容"

# 发布文章
python scripts/publish_article.py --media_id <草稿ID>

Data intercommunication: Articles published by scripts are automatically recorded in the database and can be viewed and managed in the Web UI.

Prerequisites

Dependencies: requests>=2.28.0, python-dotenv>=1.0.0, fastapi>=0.104.1, sqlalchemy>=2.0.35

Credential configuration:

  • Configure in the .env file WECHAT_APP_ID and WECHAT_APP_SECRET
  • How to obtain: WeChat Official Platform → Development → Basic Configuration
  • IP whitelist configuration required

Database: Automatically creates a SQLite database (data/articles.db); no manual configuration required

Standard Process (Web UI)

1. Start the service

cd skills/good-mp-post
uvicorn app.main:app --reload

2. Create an article

  • Open http://localhost:8000
  • Fill in the title, author, and summary
  • Write Markdown content
  • Save the draft

3. Publish the article

  • Click the "Publish" button in the article list
  • Automatically handles cover image upload, draft creation, and publishing process
  • Check the publishing status

Script Process (Command Line)

1. Create article content

  • Create an article according to user needs (Markdown format)
  • Refer to assets/templates/article-template.md for formatting suggestions

2. Generate images

  • Generate a cover image (recommended 900×383px, <5MB)
  • Generate illustrations (width ≤900px)

3. Upload images

Call scripts/upload_media.py:

python scripts/upload_media.py /path/to/cover.jpg thumb    # 封面图
python scripts/upload_media.py /path/to/image.png image    # 正文图

4. Create a draft

Call scripts/create_draft.py:

python scripts/create_draft.py \
  --title "文章标题" \
  --author "作者名" \
  --thumb_media_id <封面图ID> \
  --content "<p>HTML正文</p>" \
  --media_ids '[]'

Note: The author name must be at most 8 Chinese characters

5. Publish the article

Call scripts/publish_article.py:

python scripts/publish_article.py --media_id <草稿ID>

Resource Index

  • app/main.py - FastAPI main application entry point
  • app/api/articles.py - Article management API
  • app/api/images.py - Image upload API
  • app/database.py - Database models and connection
  • app/static/index.html - Web UI interface
  • scripts/upload_media.py - Upload images to the material library
  • scripts/create_draft.py - Create an image-text draft
  • scripts/publish_article.py - Publish the draft
  • scripts/db_logger.py - Database logging (optional)
  • references/api-guide.md - Detailed API documentation
  • assets/templates/article-template.md - Article format template

Image Path Specifications (Important)

The following specifications must be followed when AI generates articles:

Do not use relative paths

❌ Incorrect example:

![封面](./cover.jpg)
![插图](../images/chart.png)
![示例](images/demo.jpg)

Correct image processing flow

  1. First generate the image file and save it to a temporary directory
  2. Call upload_media.py to upload to WeChat and obtain the media_id
  3. Use placeholders or descriptive text; do not directly insert local paths

✅ Correct example:

<!-- 步骤1:生成图片 -->
<!-- 步骤2:上传图片 -->
python scripts/upload_media.py /path/to/cover.jpg thumb

<!-- 步骤3:记录 media_id,在创建草稿时使用 -->
<!-- 正文中不插入相对路径 -->

Reason

  • Relative paths cannot be displayed properly during preview and publishing
  • The WeChat Official Account requires uploading the image first to obtain a media_id
  • The existing workflow (upload image → create draft) is correct

Key considerations

  1. Author name limit: maximum 8 Chinese characters
  2. Image validity period: cover images are permanent, body images last 3 days
  3. Image path: relative paths are prohibited (see the image path specification above)
  4. HTML requirements: use simple tags (p/h1-h3/ul/li/img/a), avoid complex CSS
  5. Publishing review: after publishing, WeChat review is required before it can be displayed
  6. Call frequency: upload 1000 times/day, create draft 100 times/day, publish 10 times/day