WeChat Official Account – Article and Image Publishing: Pushing Markdown into the WeChat Official Account Draft Box

Preface

When running a WeChat Official Account, the typical workflow is: write the draft in Markdown locally, then copy it into the backend editor to adjust styles, upload images, and add a cover. Long-form articles and image carousels (multi-image horizontal scrolling) differ in APIs and fields, and manually switching between them can cause steps to be missed.

Below we introduce the WeChat Official Account – Article & Image Publishing skill on SkillHub (coordinate @user_dfcfbf47/weixin-publisher). On the Agent side it provides an executable publishing spec and scripts: it renders Markdown into WeChat-ready content and calls the draft API to write it, rather than assembling HTML ad-hoc in a chat.

What Is This

WeChat Official Account – Article & Image Publishing is a community-sourced (community) content-creation Skill maintained by publisher user_dfcfbf47, currently registered on SkillHub as version 1.0.1. Official entry points:

  • API coordinate: https://api.skillhub.cn/user_dfcfbf47/weixin-publisher
  • Display page: https://www.skillhub.cn/skills/user_dfcfbf47/weixin-publisher

The brief matches the page: one-click publish Markdown to the WeChat Official Account draft box, supporting both article messages (long-form) and image messages (carousels). The SkillHub tag requires_api_key=true means you must configure the Official Account AppID / AppSecret before use (see the credentials file below).

Core Functions

Based on the SKILL.md and scripts in the Skill package, the verified capabilities are as follows.

Article Message (Long-form)

  • Entry point: scripts/publish.sh → scripts/publish_article.py.
  • Pipeline: Markdown parsing → theme CSS inlining → code highlighting → inline image upload and replacement → call draft/add to create a draft; after publishing, self-checks are performed via draft/count and draft/get.
  • Dependencies: The article path primarily uses the Python 3.9+ standard library, without external layout CLIs.
  • Optional features: Multiple layout themes and highlight themes, link-to-footnote conversion (external links in WeChat articles are easily filtered), --render-only for local-only preview, and inline SVG preprocessing via scripts/svg2wechat.py (SVG files cannot be uploaded directly in carousel mode).
  • Entry point: scripts/wechat-image-post.py (requires requests to be installed).
  • Form: article_type=newspic; the image list is passed via image_info; content is a plain-text caption, not HTML.
  • Cover: The first image or the cover field in frontmatter; the script handles resizing (the cover must meet size limits, see the Skill doc’s error code table).

Credentials & Cache

  • Credentials: WECHAT_APP_ID, WECHAT_APP_SECRET, read by default from ~/.wechat-credentials.env. You can specify another path with the environment variable WECHAT_CRED_FILE; alternatively, source the Skill’s scripts/setup.sh to load them.
  • Token & uploads: access_token is cached at ~/.config/wechat-publisher/token.json; image uploads are deduplicated by md5 at ~/.config/wechat-publisher/upload-cache.json.

Installation & Activation

1. Install the SkillHub CLI (if not already installed)

Check or install the CLI per the SkillHub installation instructions:

command -v skillhub && skillhub --version

If not installed, run (full installation example):

curl -fsSL https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/install.sh | bash

See https://skillhub.cn/install/skillhub.md for details.

2. Install this Skill

When installing, you must use --dir to point to your Agent’s current skills directory; otherwise it defaults to ./skills/ and may not be recognized.

skillhub install @user_dfcfbf47/weixin-publisher --dir <your skills directory>

Common paths (from the SkillHub installation doc):

  • Cursor: ~/.cursor/skills/
  • Claude Code: ~/.claude/skills/
  • Codex: ~/.codex/skills/ or .agents/skills/ under the project

The SkillHub page also lets you hand the following prompt to an AI, which will complete the installation per the same documentation:

Please install `@user_dfcfbf47/weixin-publisher` according to https://skillhub.cn/install/skillhub.md.

After installation, @user_dfcfbf47/weixin-publisher will appear under the corresponding skills directory (containing SKILL.md and scripts/). To activate, have your Agent load this Skill and invoke the scripts per SKILL.md; after modifying Skill files you usually need to restart or re-load the Agent session.

3. Configure Official Account credentials

Create a credentials file on the machine running the publishing scripts (path is customizable; default shown below):

# ~/.wechat-credentials.env
export WECHAT_APP_ID=your_wechat_app_id
export WECHAT_APP_SECRET=your_wechat_app_secret

Load the environment variables before publishing, e.g.:

source ~/.wechat-credentials.env
# or: source <skill install dir>/scripts/setup.sh

You must also add the public IP of the machine running the scripts to the WeChat Official Account whitelist; otherwise the API may return 40164. The AppID / AppSecret are obtained from the Official Account backend under “Settings & Development → Basic Configuration” (the Skill’s README has corresponding instructions).

Typical Usage

In the paths below, replace <skill> with your local installation directory, e.g., under Cursor it’s often ~/.cursor/skills/@user_dfcfbf47/weixin-publisher.

Long-form article

  1. Prepare a Markdown file with frontmatter (title required; cover, description, author, theme optional):
---
title: Article title (required)
cover: ./assets/cover.jpg
description: Article summary
author: Author name
theme: lapis
---

# Start of body

Your content, supporting Markdown syntax...
  1. Publish to the draft box:
source ~/.wechat-credentials.env
bash <skill>/scripts/publish.sh /path/to/article.md

Specify theme and highlight theme (second and third arguments):

bash <skill>/scripts/publish.sh /path/to/article.md lapis solarized-light

Render only, without calling the WeChat APIs:

python3 <skill>/scripts/publish_article.py /path/to/article.md \
  --theme lapis --highlight github \
  --render-only preview.html

The Skill package includes example.md, which can be used as a minimal integration sample:

bash <skill>/scripts/publish.sh <skill>/example.md
  1. Fill in title, cover, etc., in frontmatter per the Skill doc; the body is a plain-text caption plus ![]() image references.

  2. After installing requests, run (the example matches the Skill doc and uses your local Python 3):

source ~/.wechat-credentials.env
pip install requests
python3 <skill>/scripts/wechat-image-post.py /path/to/post.md

After successful publishing, verify in the WeChat Official Account platform draft box; it does not auto-mass-send; you must still confirm and send manually in the backend.

Use Cases & Notes

Who it’s for

  • Teams or individuals already writing in Skills-capable environments like Cursor, Claude Code, or Codex who want to codify “layout + image upload + draft creation” into a fixed scripted path.
  • Those who need to cover both Official Account long-form and carousel draft types and want post-publish self-checks like draft/get to reduce silent failures of “API succeeded but draft is wrong”.

Limitations & common pitfalls

  • The target is only the draft box, not one-click mass-send to followers; you still need backend review and manual sending before going live.
  • In carousel mode, the caption is plain text; do not treat it as HTML; URL-style content in captions may trigger errors like 45166 (see the SKILL.md error code table).
  • Uploading SVG files in carousel mode will fail; if using vector graphics in long-form, follow the docs to inline SVG or convert to bitmaps.
  • The article and carousel paths have different Python dependencies: carousel requires requests; when running in an isolated venv, use the interpreter path with the dependencies installed.
  • The public IP of the running environment must be in the whitelist; credential errors, expired tokens, cover size limits, etc., have corresponding error codes and suggestions in the Skill doc (e.g., delete ~/.config/wechat-publisher/token.json and retry).

SkillHub stats (at time of capture): rating 100000, about 1479 downloads; specific numbers are subject to the SkillHub page’s real-time display.

Conclusion

WeChat Official Account – Article & Image Publishing codifies the steps between Markdown drafting and the WeChat Official Account draft API into the Skill and scripts: long-form uses in-house rendering and theme inlining; carousels use the newspic multi-image structure; it emphasizes post-publish self-checks and ops details like credentials/IP whitelists. If you want stable draft output within your Agent workflow, install @user_dfcfbf47/weixin-publisher from SkillHub, configure credentials per the package’s SKILL.md, and try example.md first.

  • Official API coordinate: https://api.skillhub.cn/user_dfcfbf47/weixin-publisher
  • SkillHub page: https://www.skillhub.cn/skills/user_dfcfbf47/weixin-publisher
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye