# 微信消息转发系统 **Repository Path**: onefly/WxMsgTransfer ## Basic Information - **Project Name**: 微信消息转发系统 - **Description**: 微信消息转发系统 - 用于接收和转发微信公众号消息,可用于服务号扫码(关注)登录等场景。全部使用AI完成开发 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-25 - **Last Updated**: 2026-05-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # WeChat Message Transfer System 微信消息转发系统 - 用于接收和转发微信公众号消息 ## Features - 接收微信公众号消息并存储到 SQLite 数据库 - 支持创建带参数二维码,扫码后自动回复消息 - 提供 RESTful API 接口供外部系统调用 - 支持扫码登录场景,提供扫码状态查询接口 - 单公众号架构,配置简单 ## Tech Stack - Go 1.20+ - Gin Web Framework - SQLite Database - WeChat Official Account API ## Installation ### Build from Source ```bash # Clone repository git clone cd WxMsgTransfer # Build for Windows go build -o wechat-receiver.exe . # Build for Linux GOOS=linux GOARCH=amd64 go build -o wechat-receiver . ``` ### Download Release Download pre-built binaries from releases page. ## Configuration ### Running the Application ```bash # Windows wechat-receiver.exe # Linux ./wechat-receiver ``` ### Default Settings - **Default Port**: 8090 - **Default Token**: `wechat_token` - **Default API Key**: `wechat_api_key` - **Database**: `wechat_data.db` ### WeChat Official Account Configuration 1. Login to [WeChat Official Platform](https://mp.weixin.qq.com/) 2. Configure Server URL: `http://your-domain:8090/transfer/wechat/receive` 3. Set Token (must match the token in system configuration) ## API Documentation ### Authentication All API requests require `X-API-KEY` header: ``` X-API-KEY: your_api_key ``` ### Endpoints | Method | Endpoint | Description | |--------|----------|-------------| | GET | `/transfer/api/config` | Get current configuration | | POST | `/transfer/api/config` | Save configuration | | GET | `/transfer/api/messages/unprocessed` | Get unprocessed messages | | GET | `/transfer/api/messages/all` | Get all messages | | POST | `/transfer/api/messages/process` | Mark messages as processed | | POST | `/transfer/api/qrcode/create` | Create QR code | | GET | `/transfer/api/qrcode/scan_status` | Check QR code scan status | | GET | `/transfer/api/error_logs` | Get error logs | | DELETE | `/transfer/api/error_logs/clear` | Clear error logs | ### Create QR Code **Request:** ```json POST /transfer/api/qrcode/create { "scene_str": "user_login_abc123", "expire_seconds": 300, "rep_msg": "Welcome!" } ``` **Response:** ```json { "code": 0, "msg": "success", "data": { "ticket": "xxx", "expire_seconds": 300, "url": "https://mp.weixin.qq.com/l/xxx", "qrcode_url": "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=xxx" } } ``` ### Check Scan Status **Request:** ``` GET /transfer/api/qrcode/scan_status?scene_key=user_login_abc123 ``` **Response (Not scanned):** ```json { "code": 0, "msg": "not scanned", "data": { "scanned": false } } ``` **Response (Scanned):** ```json { "code": 0, "msg": "scanned", "data": { "scanned": true, "open_id": "oXXXX", "scan_time": "2026-05-25 10:00:00" } } ``` ## Web Interface Access the web management interface at: ``` http://your-domain:8090/transfer ``` ### Features - Message list view - Configuration management - QR code generation - Error logs view ## Project Structure ``` WxMsgTransfer/ ├── main.go # Entry point ├── config.go # Configuration management ├── database.go # Database operations ├── message.go # Message handling ├── qrcode.go # QR code operations ├── routes.go # HTTP routes ├── models.go # Data models ├── errorlog.go # Error logging ├── templates/ │ └── index.html # Web interface └── wechat_data.db # SQLite database (auto-generated) ``` ## License MIT License ## Contact For issues and support, please open an issue in the repository.