Webhook 让平台在事件发生时主动推送 JSON 到你的 HTTPS 回调地址,比轮询更实时且省配额。
| Event | 说明 |
|---|---|
resource.published |
资源发布 |
resource.updated |
资源更新 |
resource.deleted |
资源删除 |
server.status.online |
服务器上线 |
server.status.offline |
服务器下线 |
post.published |
帖子发布 |
post.deleted |
帖子删除 |
进入 Webhook 管理 页面:
平台向你的 URL 发送 POST 请求:
POST /your-callback HTTP/1.1
Host: your-domain.com
Content-Type: application/json
X-Webhook-Event: resource.published
X-Webhook-Signature: <hex>
X-Webhook-Timestamp: 1735000000000
{
"event": "resource.published",
"data": { "postId": 12345, "title": "...", "..." }
}
expected = HMAC_SHA256( secret, X-Webhook-Timestamp + "\n" + raw_body ).hex()
if !constantTimeEquals(expected, X-Webhook-Signature): reject
伪代码(Node.js):
import crypto from 'crypto'
function verify(req, secret) {
const ts = req.headers['x-webhook-timestamp']
const sig = req.headers['x-webhook-signature']
const expected = crypto.createHmac('sha256', secret)
.update(`${ts}\n${req.rawBody}`)
.digest('hex')
return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(sig))
}
2xx(默认超时 10s)非 2xx 或超时会自动进入重试队列:
如下游临时故障,可在 Webhook 管理页把状态切到 PAUSED。期间事件不会进入投递队列。
PAUSED:暂停期间事件不会进入投递队列。2xx ACK 再异步处理。X-Webhook-Timestamp + "\n" + 原始 body。详细字段定义见 API Reference 里 webhook 部分。