Javascript 为什么twilio不从url读取xml?
这是代码,我希望twilio从一个post路由读取,但它不从那里读取xlm,我希望从用户那里获取数字,根据调用期间的输入,然后我希望流基于该输入工作Javascript 为什么twilio不从url读取xml?,javascript,twilio,twilio-twiml,Javascript,Twilio,Twilio Twiml,这是代码,我希望twilio从一个post路由读取,但它不从那里读取xlm,我希望从用户那里获取数字,根据调用期间的输入,然后我希望流基于该输入工作 .create({ method: 'POST', url: 'https://stormy-everglades-64562.herokuapp.com/voice', to: '+923047931504', from: '+17207344485' })
.create({
method: 'POST',
url: 'https://stormy-everglades-64562.herokuapp.com/voice',
to: '+923047931504',
from: '+17207344485'
})
.then(call => console.log(call.sid));
app.post('/voice', (request, response) => {
// Create TwiML response
const twiml = new VoiceResponse();
twiml.gather(
{
numDigits: 1,
action: '/gather',
},
gatherNode => {
gatherNode.say('For sales, press 1. For support, press 2.');
}
);
// If the user doesn't enter input, loop
twiml.redirect('/voice');
// Render the response as XML in reply to the webhook request
response.type('text/xml');
response.send(twiml.toString());
});```
请尝试以下方法:
app.post('/voice', (request, response) => {
// Create TwiML response
const twiml = new twilio.twiml.VoiceResponse();
const gather = twiml.gather(
{
numDigits: 1,
action: '/gather',
})
gather.say('For sales, press 1. For support, press 2.');
// If the user doesn't enter input, loop
twiml.redirect('/voice');
// res.set('Content-Type','text/xml');
response.type('text/xml');
response.send(twiml.toString());
});