【问题标题】:twilio recordingStatusCallback is not sending parameters to urltwilio recordingStatusCallback 没有向 url 发送参数
【发布时间】:2020-12-22 18:35:44
【问题描述】:

我想发送一个带有recordingStatusCallback url 的号码。但是,当我收到 web-hook url 中的参数日志时,我没有看到我在 URL 中传递的参数。我将参数解析为 url-endcoded 格式。 下面的代码,我在url中发送了chunkStartNumber=18,但是在下面的日志中没有chunkStartNumber的痕迹

   var recLenDivided=18;
   let twiml = new Twilio.twiml.VoiceResponse();
    twiml.record({
        action:`https://xyz`,
        method: 'GET',
        finishOnKey: '5',
        recordingStatusCallback:`http://xyz/hookFolder?chunkStartNumber=${recLenDivided}`
    });
      return callback(null, twiml);
   }

解析器代码

const express = require ('express')
const bodyParser = require ('body-parser')
const app = express()
const PORT = 3000


app.use(express.static("public"))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended:true}))

app.post("/hookFolder",(req, res) => {
    console.log(req.body)
     
    res.status(200).end()
}) 

日志

{ RecordingSource: 'RecordVerb',RecordingSid: 'RE', RecordingUrl: 'https://api.twilio.com/2010-04-01/', RecordingStatus: 'completed', RecordingChannels: '1', ErrorCode: '0', CallSid: 'CA', RecordingStartTime: 'Tue, 22 Dec 2020 18:09:44 +0000', AccountSid: 'AC', RecordingDuration: '9' }

【问题讨论】:

    标签: twilio url-parameters recording


    【解决方案1】:

    试试 req.query。

    另外,不需要使用 Bodyparser。内置于更高版本的 Express。

    app.use(express.json());

    app.use(express.urlencoded({ extended: false }));

    【讨论】:

    • 太好了,我相信您的回答提供了有关最佳实践的想法。但是额外使用 bodyparser 会产生任何缺点吗?
    • 不需要它,因为它现在包含在 Express.js 中。除了外部依赖之外,我无法回答有关缺点的问题。
    猜你喜欢
    • 2016-11-14
    • 1970-01-01
    • 2019-05-08
    • 2013-11-11
    • 2019-11-13
    • 2011-03-16
    • 1970-01-01
    • 1970-01-01
    • 2020-11-13
    相关资源
    最近更新 更多