Files
wecom-ai-assistant/docs/phase4.md
2026-02-05 16:36:32 +08:00

19 lines
951 B
Markdown
Raw Permalink 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.
# Phase 4企业微信回调打通GET 验签 + POST echo
## 新增内容
- **GET /api/wecom/callback**:使用 `WECOM_TOKEN``WECOM_ENCODING_AES_KEY` 验签并解密 `echostr`,将解密结果原样返回。
- **POST /api/wecom/callback**:解析加密 XML验签、解密、解析消息文本消息 echo 回复,回复加密后以 XML 返回。
- **加解密**`app/services/wecom_crypto.py`SHA1 验签、AES-256-CBC 加解密,与企微文档一致)。
## 验证
1. 在企微管理后台配置回调 URL`https://你的域名/api/wecom/callback`,填 Token、EncodingAESKey。
2. 保存后企微会发 GET 校验,服务端应返回解密后的 echostr后台显示「保存成功」。
3. 给应用发一条文本消息,应收到 echo 回复。
## 关键配置
- `WECOM_TOKEN``WECOM_ENCODING_AES_KEY` 必须与企微后台一致。
- `WECOM_CORP_ID` 用于回复加密尾部POST 回复时需正确。