如何 return 对短信请求进行空响应?

How to return an empty response to an sms request?

如何在处理完短信后 return 什么都没有返回到 twilio 进程?

api 中的示例使用 MessagingResponse,当使用它时,它作为 Direction='reply' 出现在控制台的消息日志中。这会产生额外费用(入站 + 回复)。简而言之,我想这样做..

app.post('/sms', (req, res) =>
{
    console.log('hello world');
}

没有收到 11200 错误。

尝试使用空字符串作为响应消息(Twilio 需要您 return 有效 XML)。

const http = require('http');
const express = require('express');
const MessagingResponse = require('twilio').twiml.MessagingResponse;

const app = express();

app.post('/sms', (req, res) => {
  const twiml = new MessagingResponse();

  // twiml.message('');

  res.writeHead(200, {'Content-Type': 'text/xml'});
  res.end(twiml.toString());
});

http.createServer(app).listen(1337, () => {
  console.log('Express server listening on port 1337');
});

来自 Twilio 文档的回答:

In order to receive incoming messages, without sending an auto-response, the Twilio app should respond with a simple empty Response - <Response></Response>.

https://support.twilio.com/hc/en-us/articles/223134127-Receive-SMS-and-MMS-Messages-without-Responding