Twilio 'RecordingUrl' 未传递到我的解析云代码

Twilio 'RecordingUrl' Not Being Passed to my Parse Cloud Code

我有一些 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);
        });

问题是没有响应 Body,只有 header。状态代码为 200,但它还表示 success/error 未被调用。我在这里错过了什么?我希望一位著名的 Twilio 爱好者能来拯救我,因为我已经浪费了一天的时间试图得到一个愚蠢的 url。输出如下:

结果:success/error 未被调用 {"domain":null,"_events":null,"_maxListeners":10,"method":"POST","url":"/handleRecording","headers": {"cache-control":"max-age=259200","content-length":"567","content-type":"application/x-www-form-urlencoded; charset=UTF-8","host":"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...(截断)

这里是 Twilio 开发人员布道者。

Twilio sends data through a POST request 时,它按照表单编码的 url 参数执行。您需要从原始主体中解析出这些内容。

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

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);
        });

如果有帮助请告诉我。