Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mp-workflow — 微信公众号文章工作流(自包含)

把 markdown 文章排成微信公众号能直接粘贴的 HTML,并直连微信公众号 API 推到草稿箱。排版(render.py)和发布(publish.py)都在本目录跑,不依赖任何外部 CLI 或在线服务,也不绑定任何特定公众号。

它做什么

  • render.py — markdown → 微信内联 <section> HTML(技术 markdown 风:中文序号标题 + 行内代码胶囊 + One Dark 代码块 + 浅色引用块)。设计规范见 DESIGN.md,markdown 约定见 SKILL.md
  • publish.py — 直连微信公众号 API:查出口 IP、取 token、传封面/正文图、建草稿。

准备

pip3 install requests
export WECHAT_APPID=<你的公众号 AppID>       # mp.weixin.qq.com → 设置与开发 → 基本配置
export WECHAT_SECRET=<你的公众号 AppSecret>  # 同页面,开发者密码

凭据只从环境变量读,不写进仓库

快速试一下排版(不需要任何凭据)

python3 render.py examples/demo.md -o /tmp/content.html --preview /tmp/preview.html
# 起个本地 http server 打开 /tmp/preview.html 看手机宽度效果(file:// 会被浏览器拦)
python3 -m http.server -d /tmp 8000   # 然后访问 http://localhost:8000/preview.html

发布

python3 publish.py myip                          # 看出口 IP 在不在白名单(见下)
python3 publish.py upload_thumb ./img/cover.png  # 封面 → media_id
python3 publish.py upload_img   ./img/01.png     # 正文图 → mmbiz url(填进 images.json 后重渲染)
python3 publish.py create_draft draft.json       # 建草稿

draft.json 结构和完整流程见 SKILL.md

微信 API 只能推草稿,最终群发要回 mp.weixin.qq.com 后台手动点「发表」(平台限制)。

IP 白名单(最常踩的坑)

公众号开发接口默认开 IP 白名单:跑 publish.py 的机器,出口公网 IP 必须在白名单里,否则报 40164python3 publish.py myip 会直接问微信「你看到我的 IP 是多少」,按回显加进后台白名单。加白名单只能手动扫码确认,微信没有对应 API。详见 SKILL.md

作为 Claude Code / Agent skill 使用

把本目录放进你的 skills 目录即可,SKILL.md 是给 agent 看的工作流说明。

许可

MIT

About

微信公众号文章工作流 skill:markdown → 技术风内联 HTML + 直连微信 API 建草稿,自包含、不依赖外部服务、不绑定特定公众号

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages