Loading...
Loading...
Compare original and translation side by side
import platform
print(platform.system()) # 返回 'Windows' / 'Darwin' / 'Linux'import platform
print(platform.system()) # Returns 'Windows' / 'Darwin' / 'Linux'wxautox4 服务只能运行在 Windows 上,不要尝试在当前设备安装或启动服务。
问题1:请提供 wxauto-restful-api 服务地址(例如 http://192.168.1.100:8000)
问题2:请提供服务的 Bearer Token(见服务端 config.yaml 的 auth.token,默认为 token)GET /v1/wechat/statusThe wxautox4 service can only run on Windows, do not attempt to install or start the service on the current device.
Question 1: Please provide the wxauto-restful-api service address (e.g. http://192.168.1.100:8000)
Question 2: Please provide the service's Bearer Token (see auth.token in the server-side config.yaml, default value is token)GET /v1/wechat/status~/.wxautox/service_status.json~/.wxautox/service_status.jsonconfig.yamlauth.tokentoken~/.wxautox/service_status.jsonauth.tokenconfig.yamltoken~/.wxautox/service_status.jsonpython scripts/wxapi.py --base-url "http://192.168.1.100:8000" --token "my-token" send "好友" "消息"# 通用(macOS/Linux/Windows)
export WXAPI_BASE_URL="http://192.168.1.100:8000"
export WXAPI_TOKEN="my-token"
# Windows PowerShell
$env:WXAPI_BASE_URL = "http://192.168.1.100:8000"
$env:WXAPI_TOKEN = "my-token"http://localhost:8000tokenpython scripts/wxapi.py --base-url "http://192.168.1.100:8000" --token "my-token" send "Friend" "Message"# General (macOS/Linux/Windows)
export WXAPI_BASE_URL="http://192.168.1.100:8000"
export WXAPI_TOKEN="my-token"
# Windows PowerShell
$env:WXAPI_BASE_URL = "http://192.168.1.100:8000"
$env:WXAPI_TOKEN = "my-token"http://localhost:8000tokenWXAPI_SERVICE_DIR~/.wxautox/service_status.jsonservice_dir../wxauto-restful-api~/wxauto-restful-apiWXAPI_SERVICE_DIRservice_dir~/.wxautox/service_status.json../wxauto-restful-api~/wxauto-restful-apimacOS / Linux 用户无需执行此节,直接使用远程服务地址即可。
pip install wxautox4需 Windows 系统,Python 3.9–3.12 64 位
wxautox4 -a your-activation-code# 进入服务目录
cd C:\path\to\wxauto-restful-api
# 启动服务
python run.pyStart-Process python -ArgumentList "run.py" -WorkingDirectory "C:\path\to\wxauto-restful-api" -WindowStyle HiddenmacOS / Linux users do not need to perform this section, just use the remote service address directly.
pip install wxautox4Requires Windows system, Python 3.9–3.12 64-bit
wxautox4 -a your-activation-codeGet activation code: https://docs.wxauto.org/plus
# Enter the service directory
cd C:\path\to\wxauto-restful-api
# Start the service
python run.pyStart-Process python -ArgumentList "run.py" -WorkingDirectory "C:\path\to\wxauto-restful-api" -WindowStyle Hiddenpython scripts/wxapi.py send "好友" "消息"python scripts/wxapi.py --helppython scripts/wxapi.py send "Friend" "Message"python scripts/wxapi.py --helpundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedpython scripts/wxapi.py --helppython scripts/wxapi.py --help| 接口 | 说明 |
|---|---|
| 初始化微信实例 |
| 获取微信状态 |
| 发送消息 |
| 发送文件 |
| 发送 URL 卡片 |
| 获取当前窗口消息 |
| 获取历史消息 |
| 获取新消息 |
| 获取会话列表 |
| 获取指定子窗口 |
| 获取所有子窗口 |
| 切换聊天窗口 |
| 获取好友列表 |
| 获取我的信息 |
| 获取群聊列表 |
| 切换到聊天页面 |
| 切换到联系人页面 |
| 检查在线状态 |
| Interface | Description |
|---|---|
| Initialize WeChat instance |
| Get WeChat status |
| Send messages |
| Send files |
| Send URL cards |
| Get messages from current window |
| Get historical messages |
| Get new messages |
| Get session list |
| Get specified sub-window |
| Get all sub-windows |
| Switch chat window |
| Get friend list |
| Get my information |
| Get group chat list |
| Switch to chat page |
| Switch to contacts page |
| Check online status |
| 接口 | 说明 |
|---|---|
| 子窗口发送消息 |
| 获取子窗口所有消息 |
| 获取子窗口新消息 |
| 发送引用消息 |
| 关闭子窗口 |
| Interface | Description |
|---|---|
| Send messages from sub-window |
| Get all messages from sub-window |
| Get new messages from sub-window |
| Send quoted messages |
| Close sub-window |
import requests
headers = {"Authorization": "Bearer token", "Content-Type": "application/json"}
body = {"who": "好友名", "msg": "消息内容"}
resp = requests.post("http://localhost:8000/v1/wechat/send", headers=headers, json=body)
print(resp.json())import requests
headers = {"Authorization": "Bearer token", "Content-Type": "application/json"}
body = {"who": "Friend Name", "msg": "Message Content"}
resp = requests.post("http://localhost:8000/v1/wechat/send", headers=headers, json=body)
print(resp.json()){
"success": true,
"message": "操作成功",
"data": { ... }
}{
"success": true,
"message": "Operation succeeded",
"data": { ... }
}http://192.168.1.100:8000config.yamlauth.tokentokenhttp://192.168.1.100:8000auth.tokenconfig.yamltoken~/.wxautox/service_status.jsonservice_dirservice_status.jsonundefinedservice_dir~/.wxautox/service_status.jsonservice_status.jsonundefined
启动后验证服务是否正常运行(检查健康接口),然后继续执行用户原本的操作。
After startup, verify whether the service is running normally (check the health interface), then continue to execute the user's original operation.config.yamlauth.tokenauth.tokenconfig.yaml