Skip to content

Commit 6b70d47

Browse files
thinkthinkingclaude
andcommitted
docs: 补充微信公众号配置流程与内容投递说明
新增「微信公众号配置流程」章节(获取 AppID/AppSecret、IP 白名单、接口权限、 凭证配置、验证、发布流水线);完善 wechat convert 的内容投递说明 (--copy / --preview / 草稿 API 三种正确投递方式与适用场景)。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c6a8477 commit 6b70d47

1 file changed

Lines changed: 66 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,71 @@ make build # 产物在 bin/thinkthinking
3434

3535
---
3636

37+
## 微信公众号配置流程
38+
39+
在使用 `wechat` 命令之前,需要先在微信公众平台获取凭证并配置到本地。
40+
41+
### 1. 获取 AppID 与 AppSecret
42+
43+
1. 登录 [微信公众平台](https://mp.weixin.qq.com/),进入「设置与开发 → 基本配置」。
44+
2. 获取或重置 `AppID`、`AppSecret`(**AppSecret 仅展示一次,请立即保存**)。
45+
3. 在「基本配置」中配置 **IP 白名单**:将调用机器的公网出口 IP 加入白名单,否则 access_token 和后续接口会被拒绝。
46+
4. 进入「设置与开发 → 接口权限」,确认以下接口可用:
47+
- 素材管理(上传/下载永久素材)
48+
- 草稿箱(新增/修改/查询草稿)
49+
- 发布能力(提交发布、查询发布状态)
50+
51+
### 2. 配置本地凭证
52+
53+
**方式一:通过 CLI 写入配置文件**
54+
55+
```bash
56+
thinkthinking init
57+
thinkthinking config set wechat.app_id wx_your_appid
58+
thinkthinking config set wechat.app_secret your_appsecret
59+
thinkthinking config list # 验证(敏感字段已脱敏)
60+
```
61+
62+
**方式二:环境变量(适合 CI/CD)**
63+
64+
```bash
65+
export WECHAT_APP_ID=wx_your_appid
66+
export WECHAT_APP_SECRET=your_appsecret
67+
```
68+
69+
### 3. 验证配置
70+
71+
```bash
72+
# 查看当前配置(敏感字段脱敏)
73+
thinkthinking config list
74+
75+
# 查看配置文件路径与加载状态
76+
thinkthinking config path
77+
```
78+
79+
`wechat draft create` 执行前会自动进行凭证预检,缺失时返回结构化 `WECHAT_AUTH_ERROR` 并附带配置路径与环境变量提示,无需手动验证。
80+
81+
### 4. 发布流水线
82+
83+
一条完整的发布路径:
84+
85+
1. **上传素材** — `wechat draft create` 自动将正文本地图片与封面图上传到微信
86+
2. **创建草稿** — 同上命令,将转换后的 HTML 写入草稿箱
87+
3. **提交发布** — (待实现,目前需在微信公众平台网页端操作)
88+
4. **查询状态** — (待实现)
89+
5. **回填文章链接** — (待实现)
90+
91+
> **参考链接**
92+
> - [微信公众平台](https://mp.weixin.qq.com/)
93+
> - [微信公众号开发概述](https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html)
94+
> - [接入指南](https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Access_Overview.html)
95+
> - [获取 access_token](https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_access_token.html)
96+
> - [新增草稿](https://developers.weixin.qq.com/doc/offiaccount/Draft_Box/Add_draft.html)
97+
> - [发布接口](https://developers.weixin.qq.com/doc/offiaccount/Publish/Publish.html)
98+
> - [微信公众号 API 整理文档](https://weixingongzhonghao.com.cn/zh/api/)
99+
100+
---
101+
37102
## 快速开始
38103

39104
```bash
@@ -58,7 +123,7 @@ thinkthinking wechat draft create --markdown-file article.md --title "文章标
58123
| 命令 | 说明 |
59124
|------|------|
60125
| `thinkthinking version` | 输出版本信息 |
61-
| `thinkthinking init [--local]` | 创建用户级(或项目级)配置 |
126+
| `thinkthinking init [--local] [--force]` | 创建用户级(或项目级)配置 |
62127
| `thinkthinking config path` | 输出配置文件路径 |
63128
| `thinkthinking config get <key>` | 读取配置项 |
64129
| `thinkthinking config set <key> <value>` | 设置配置项 |

0 commit comments

Comments
 (0)