通过简单的 HTTP 请求,将文字消息转发到企业微信群聊机器人。
支持 GET / POST 两种方式,开箱即用。
调用示例
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";
?>