要捕获来自Zoom的Webhook,您可以使用Node.js编写一个简单的Web服务器来接收和处理来自Zoom的HTTP POST请求。以下是一个示例代码:
const http = require('http');
const server = http.createServer((req, res) => {
let body = '';
req.on('data', (chunk) => {
body += chunk;
});
req.on('end', () => {
// 在这里处理接收到的数据
console.log('Received webhook data:', body);
// 响应Zoom的请求
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Webhook received successfully');
});
});
const port = 3000;
server.listen(port, () => {
console.log(`Server running on port ${port}`);
});
上述代码创建了一个简单的HTTP服务器,监听在本地的3000端口。当收到来自Zoom的Webhook请求时,它会将请求体解析为字符串并打印到控制台。然后,它将发送一个200响应给Zoom。
您可以将上述代码保存为webhook.js
文件,并使用以下命令启动服务器:
node webhook.js
然后,您可以将Zoom的Webhook URL配置为http://localhost:3000
,以便将Webhook事件发送到您的本地服务器。
上一篇:捕捉来自子脚本的错误