baoyu-post-to-wechat
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesebaoyu-post-to-wechat (Community Edition)
baoyu-post-to-wechat (社区版)
Community edition posts directly to WeChat Official Account API from local machine.
社区版可直接从本地设备调用微信公众号API发布内容。
Runtime
运行环境
- Entry script:
scripts/wechat-api.ts - Run command:
bash
bun .agents/skills/baoyu-post-to-wechat/scripts/wechat-api.ts <file> [options]- 入口脚本:
scripts/wechat-api.ts - 运行命令:
bash
bun .agents/skills/baoyu-post-to-wechat/scripts/wechat-api.ts <file> [options]Credentials
凭证配置
Put credentials in shared :
.agents/skills/.envdotenv
WECHAT_APP_ID=...
WECHAT_APP_SECRET=...Resolution order:
- Process env
.agents/skills/.env
将凭证存入共享的 文件:
.agents/skills/.envdotenv
WECHAT_APP_ID=...
WECHAT_APP_SECRET=...读取优先级顺序:
- 进程环境变量
- 文件
.agents/skills/.env
Scope
适用范围
This skill only targets draft box saving (), not mass-send.
draft/add本工具仅支持保存到草稿箱(接口),不支持群发功能。
draft/addPublishing Rules
发布规则
- Cover image uses permanent material API (, type=image), obtains
material/add_material.thumb_media_id - Inline images in article HTML use , obtains public
media/uploadimg.url - Save draft through with article payload.
draft/add - ,
need_open_comment=1by default.only_fans_can_comment=0
- 封面图调用永久素材API(, type=image),获取
material/add_material。thumb_media_id - 文章HTML中的内嵌图片调用接口,获取公开可访问的
media/uploadimg。url - 携带文章请求参数通过接口保存草稿。
draft/add - 默认配置为(开启评论)、
need_open_comment=1(非仅粉丝可评论)。only_fans_can_comment=0
Official API Mapping
官方API映射
- (
draft/add):article_type=news- must be a permanent
thumb_media_id.media_id - image URLs must come from
content.media/uploadimg
- : cover and other permanent image assets.
material/add_material?type=image - : inline images for article HTML content.
media/uploadimg
- (
draft/add):article_type=news- 必须是永久有效的
thumb_media_id。media_id - 字段中的图片URL必须来自
content接口的返回值。media/uploadimg
- : 用于上传封面图和其他永久图片素材。
material/add_material?type=image - : 用于上传文章HTML内容中的内嵌图片。
media/uploadimg
Recommended Operation Order
推荐操作流程
- Normalize Obsidian image syntax (including ) to standard markdown image form.
![[...]] - Render markdown to HTML.
- Upload inline images with and replace
uploadimgwith returned URLs.<img src> - Upload cover with permanent material API and get .
thumb_media_id - Call .
draft/add
- 将Obsidian图片语法(包括)统一转换为标准Markdown图片格式。
![[...]] - 将Markdown内容渲染为HTML。
- 调用接口上传内嵌图片,用返回的URL替换
uploadimg属性值。<img src> - 调用永久素材API上传封面图,获取。
thumb_media_id - 调用接口。
draft/add
Input
输入格式
- or
.md.html - If input is markdown, script converts markdown first, then uploads inline images and publishes.
- 支持或
.md格式文件.html - 如果输入为Markdown格式,脚本会先完成格式转换,再上传内嵌图片并发布。
Examples
使用示例
bash
undefinedbash
undefinedBasic markdown draft publish
基础Markdown草稿发布
bun .agents/skills/baoyu-post-to-wechat/scripts/wechat-api.ts article.md
bun .agents/skills/baoyu-post-to-wechat/scripts/wechat-api.ts article.md
Explicit cover and metadata
显式指定封面和元数据
bun .agents/skills/baoyu-post-to-wechat/scripts/wechat-api.ts article.md
--cover Assets/Cover-Images/my-topic/cover.jpg
--title "标题"
--author "作者"
--summary "摘要"
--cover Assets/Cover-Images/my-topic/cover.jpg
--title "标题"
--author "作者"
--summary "摘要"
bun .agents/skills/baoyu-post-to-wechat/scripts/wechat-api.ts article.md
--cover Assets/Cover-Images/my-topic/cover.jpg
--title "标题"
--author "作者"
--summary "摘要"
--cover Assets/Cover-Images/my-topic/cover.jpg
--title "标题"
--author "作者"
--summary "摘要"
HTML input
HTML输入格式
bun .agents/skills/baoyu-post-to-wechat/scripts/wechat-api.ts article.html --cover Assets/cover.jpg
undefinedbun .agents/skills/baoyu-post-to-wechat/scripts/wechat-api.ts article.html --cover Assets/cover.jpg
undefinedNotes
注意事项
- WeChat requires inline article images to come from URLs.
uploadimg - Cover and inline image APIs are different and both are required for stable draft publishing.
- 微信要求文章内嵌图片的URL必须来自接口的返回值。
uploadimg - 封面图和内嵌图片使用的API不同,二者都需正确调用才能保证草稿发布稳定。