企业微信消息 Worker

服务运行正常

本服务用于通过企业微信自建应用发送文本消息。

接口地址

POST https://wapp.021529.xyz/send

认证方式

通过 HTTP 请求头提供调用密钥:

Authorization: Bearer YOUR_SEND_API_KEY
请将 YOUR_SEND_API_KEY 替换为 Worker 中配置的 SEND_API_KEY

请求参数

字段 类型 是否必需 说明
to_user string 企业微信成员账号。省略时使用 DEFAULT_TO_USER, 当前默认值为 Samuel
msg_content string 需要发送的文本消息内容。

cURL 示例

curl -X POST 'https://wapp.021529.xyz/send' \
  -H 'Authorization: Bearer YOUR_SEND_API_KEY' \
  -H 'Content-Type: application/json' \
  --data '{
    "to_user": "Samuel",
    "msg_content": "Hello, this is a test message!"
  }'

PowerShell 示例

$headers = @{
    Authorization = "Bearer YOUR_SEND_API_KEY"
}

$body = @{
    to_user     = "Samuel"
    msg_content = "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss'): Hello, this is a test message!"
} | ConvertTo-Json

Invoke-RestMethod `
    -Method Post `
    -Uri "https://wapp.021529.xyz/send" `
    -Headers $headers `
    -ContentType "application/json" `
    -Body $body

Python 示例

import requests
from datetime import datetime

url = "https://wapp.021529.xyz/send"

headers = {
    "Authorization": "Bearer YOUR_SEND_API_KEY",
    "Content-Type": "application/json"
}

payload = {
    "to_user": "Samuel",
    "msg_content": f"{datetime.now():%Y-%m-%d %H:%M:%S}: Hello, this is a test message!"
}

response = requests.post(
    url,
    headers=headers,
    json=payload,
    timeout=10
)

print(response.status_code)
print(response.json())

成功响应示例

{
  "ok": true,
  "wecom": {
    "errcode": 0,
    "errmsg": "ok"
  }
}

错误响应示例

{
  "ok": false,
  "error": "Unauthorized"
}