⚡ EdgeOne Pages

📬 企业微信通知转发器

通过简单的 HTTP 请求,将文字消息转发到企业微信群聊机器人。 支持 GET / POST 两种方式,开箱即用。

项目简介

本项目部署在 Tencent EdgeOne Pages 上,利用其边缘函数能力, 提供了一个轻量级的通知转发 API。你只需向 /notify 路径发送 带 content 参数的请求,即可将消息推送至企业微信群。 所有敏感配置(Webhook 地址、访问令牌)均通过环境变量管理,安全可靠。

使用说明
⚠️ 安全建议:请始终使用 Authorization 请求头传递 Token, 避免将敏感信息暴露在 URL 日志或浏览器历史中。
GET
/notify?content=你好
需在 Header 中携带 Authorization
POST
/notify
支持 JSON / 表单 / 纯文本请求体
调用示例

cURL

# GET 请求(Header 鉴权) curl "https://your-domain.edgeone.app/notify?content=Hello%20World" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" # POST 请求(JSON 请求体) curl -X POST "https://your-domain.edgeone.app/notify" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{"content": "Hello World"}'

JavaScript (fetch)

const notify = async (content) => { const response = await fetch('https://your-domain.edgeone.app/notify', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_ACCESS_TOKEN', 'Content-Type': 'application/json' }, body: JSON.stringify({ content }) }); const data = await response.text(); console.log(`Status: ${response.status}`, data); }; notify('前端构建完成');

Python

import requests url = "https://your-domain.edgeone.app/notify" headers = { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json" } payload = {"content": "定时任务执行成功"} response = requests.post(url, headers=headers, json=payload) print(f"Status Code: {response.status_code}") print(f"Response: {response.text}")

PHP

<?php $url = 'https://your-domain.edgeone.app/notify'; $token = 'YOUR_ACCESS_TOKEN'; $content = 'Hello from PHP'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer ' . $token, 'Content-Type: application/json' ]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['content' => $content])); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); echo "HTTP Status: $httpCode\n"; echo "Response: $response\n"; ?>
响应与错误码