mp_chajian/README.md
2025-10-15 16:46:31 +08:00

72 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 微信公众号插件API
这是一个基于FastAPI构建的微信公众号插件API服务提供以下功能
1. 获取微信公众号access_token
2. 上传临时图片到微信公众号素材库
3. 上传永久图片到微信公众号素材库
4. 上传文章草稿到微信公众号
## 安装依赖
```bash
pip install -r requirements.txt
```
## 启动服务
```bash
python main.py
```
服务将在 `http://localhost:8000` 上运行。
## API文档
启动服务后可以通过以下地址访问API文档
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
## API接口说明
### 1. 获取access_token
- **URL**: `/token`
- **方法**: POST
- **参数**:
- `appid` (string): 公众号的APPID
- `appsecret` (string): 公众号的AppSecret
- **返回**: access_token
### 2. 上传临时图片
- **URL**: `/upload_temp_image`
- **方法**: POST
- **参数**:
- `access_token` (string): 公众号的access_token
- `image_url` (string): 图片的URL地址
- **返回**: media_id
### 3. 上传永久图片
- **URL**: `/upload_permanent_image`
- **方法**: POST
- **参数**:
- `access_token` (string): 公众号的access_token
- `image_url` (string): 图片的URL地址
- **返回**: 永久素材的media_id
### 4. 上传文章草稿
- **URL**: `/upload_draft`
- **方法**: POST
- **参数**:
- `access_token` (string): 公众号的access_token
- `title` (string): 文章标题
- `content` (string): 文章内容HTML格式
- `cover_media_id` (string): 封面图片的media_id
- `author` (string): 作者
- `digest` (string, optional): 文章摘要
- `show_cover_pic` (int, optional): 是否显示封面0不显示1显示默认为1
- **返回**: 草稿的media_id