gpt4 book ai didi

javascript - Twilio 'RecordingUrl' 未传递到我的 Parse Cloud 代码

转载 作者:行者123 更新时间:2023-12-03 06:08:38 25 4
gpt4 key购买 nike

我有一些 php Twiml,可以在启动一些 Parse Cloud 代码来检索 RecordingUrl 之前成功进行调用并记录它们:

$response->dial($callee, array(action=>"https://myApp.parseapp.com/handleRecording", 'callerId'=>$callerId, record=>true));

我的解析云代码如下:

// Include Cloud Code module dependencies
var express = require('express'),
twilio = require('twilio');

var app = express();
twilio.initialize("ACr245kl2hj54245245324","252k5kjk5j4525234252525252b54v5");

app.post('/handleRecording', function(request, response){
//var recUrl = request.body.RecordingUrl + ".wav"; // This is
//var recUrl = request.params.RecordingUrl + ".wav"; // always nil
console.log(request);
console.log(response);
});

问题是没有响应正文,只有 header 。状态代码是 200,但它也表示未调用成功/错误。我在这里缺少什么?我希望一位著名的 Twilio 爱好者能够前来救援,因为我已经浪费了一天时间试图获取一个愚蠢的网址。输出如下:

结果:未调用成功/错误{“domain”:null,“_events”:null,“_maxListeners”:10,“method”:“POST”,“url”:“/handleRecording”,“headers”:{“cache-control”:“max-年龄=259200","内容长度":"567","内容类型":"application/x-www-form-urlencoded; charset=UTF-8","主机":"myApp.parseapp.com","referer":"https://myAppsTwilioServer.herokuapp.com/twiml.php ","user-agent":"TwilioProxy/1.1","version":"HTTP/1.1","x-forwarded-for":"10.252.1.70","x- forwarded-proto":"https","x-twilio-signature":"24958u49843985934579kjkjdf45="},"httpVersion":["HTTP/1.1","1.1"],"connection":{},"originalUrl": "/handleRecording","_parsedUrl":{"protocol":null,"slashes":null,"auth":null,"host":null,"port":null,"hostname":null,"hash": null,"search":null,"query":null,"pathname":"/handleRecording","path":"/handleRecording","href":"/handleRecording"},"query":{},"res":{"domain":null,"_events":null,"_maxListeners":10,"statusCode":200,"headersSent":false,"sendDate":true,"req":{},"viewCallbacks":[],"_hasConnectPatch":true},"_route_index":0,"route":{"pat...( chop )

最佳答案

这里是 Twilio 开发者布道者。

何时 Twilio sends data through a POST request ,它以表单编码的 url 参数的形式进行。您需要从原始主体中解析出它们。

通常的方法是安装express的body-parser通过 npm 模块,然后使用它来解析传入的请求主体,如下所示:

var express = require('express'),
bodyParser = require('body-parser'),
twilio = require('twilio');

var app = express();
app.use(bodyParser.urlencoded({ extended: false }))
twilio.initialize("{{ AccountSid }}","{{ AuthToken }}");

app.post('/handleRecording', function(request, response){
//var recUrl = request.body.RecordingUrl + ".wav"; // This is
//var recUrl = request.params.RecordingUrl + ".wav"; // always nil
console.log(request);
console.log(response);
});

请告诉我这是否有帮助。

关于javascript - Twilio 'RecordingUrl' 未传递到我的 Parse Cloud 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39423786/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com