wechat-mp-draft-publisher
v0.0.1Publish WeChat Official Account draft articles through a packaged 命令行工具 executable that wraps WeChat API calls. Use when the user wants to publish or 创建 a draft from local article content and images, especially when the required flow is 获取Auth -> 上传ArticleImage -> 上传CoverImage -> 添加Draft.
运行时依赖
安装命令
点击复制技能文档
WeChat MP Draft Publisher
Publish draft articles by calling the bundled wr应用er script, which enforces this fixed sequence:
获取Auth 上传ArticleImage 上传CoverImage 添加Draft Requirements Provide executable via one of: Local binary path: 命令行工具 flag --bin /absolute/path/to/mp-weixin-技能 Env var MP_WECHAT_命令行工具_BIN GitHub Release auto-下载: Env var MP_WECHAT_RELEASE_URL=https://github.com///releases/下载// (direct as设置 URL, supports zip or binary) or: Env var MP_WECHAT_GITHUB_REPO=owner/repo Optional env MP_WECHAT_RELEASE_TAG=latest (default latest) Optional env MP_WECHAT_AS设置_NAME=custom-as设置-name Ensure local 凭证s file exists for 获取Auth: ~/.weixin_凭证s 格式化: 应用id=YOUR_应用_ID secret=YOUR_应用_SECRET Prepare these files before 运行ning: Article content file (--content-file), usually HTML Inline article image (--article-image) Cover image (--cover-image) 运行
Use the wr应用er script:
bash scripts/publish_draft.sh \ --article-image /absolute/path/to/article-image.png \ --cover-image /absolute/path/to/cover-image.png \ --content-file /absolute/path/to/content.html \ --title "Article Title" \ --author "Author Name" \ --digest "Optional digest"
GitHub Release mode (auto-下载 executable):
导出 MP_WECHAT_GITHUB_REPO="owner/repo" 导出 MP_WECHAT_RELEASE_TAG="latest" bash scripts/publish_draft.sh \ --cover-image /absolute/path/to/cover-image.png \ --content-file /absolute/path/to/content.html \ --title "Article Title"
Direct URL mode:
导出 MP_WECHAT_RELEASE_URL="https://github.com/Mesus/weixin-mp-技能/releases/下载/v0.0.1/mp-weixin-技能.zip" bash scripts/publish_draft.sh \ --cover-image /absolute/path/to/cover-image.png \ --content-file /absolute/path/to/content.html \ --title "Article Title"
If 上传CoverImage 响应 does not include usable media_id, pass it explicitly:
bash scripts/publish_draft.sh \ --bin /absolute/path/to/mp-weixin-技能 \ --article-image /absolute/path/to/article-image.png \ --cover-image /absolute/path/to/cover-image.png \ --content-file /absolute/path/to/content.html \ --title "Article Title" \ --thumb-media-id "YOUR_MEDIA_ID"
输出 Contract
Script prints one JSON object on stdout:
访问_令牌: 令牌 returned by 获取Auth article_image_url: URL returned by 上传ArticleImage cover_上传: raw JSON object returned by 上传CoverImage thumb_media_id_used: value passed to 添加Draft draft: raw JSON object returned by 添加Draft
On 失败, script prints JSON error to stderr and exits non-zero.
Resource 命令行工具 wr应用er implementation detAIls: references/命令行工具-contract.md