调用 Twilio 号码时查询用户 Table

Querying User Table when Twilio number is called

我使用 Parse.com 作为后端服务。当有人拨打 twilio 号码时,我想在云代码中检测呼叫者 phone 号码,然后查询相应的用户 phone 号码。我能够通过 request.param('From') 获得呼叫者号码,但是我查询该用户失败。我尝试以多种形式在 /hello 函数内部查询,但没有成功。我使用了适用于其他云功能的同一组查询。查询记录为未定义。为什么会这样? Xcode:

 NSString *callString = [NSString stringWithFormat:@"telprompt://twilioNumber"];

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callString]];

解析云代码

    //Someone calling twilio number
    app.get('/hello', function(request, response) {
    var twiml = new twilio.TwimlResponse('');

var query = new Parse.Query(Parse.User);
  query.equalTo("PhoneNumber", request.param('From'));
    query.first({
            success: function(result) {
            var foundusr = result;
        var receiver = foundusr.get("Receiver");
twiml.dial({callerId:'twilioNumber'}, receiver);
},
            error: function(error) {response.error("Error updating user passcode"); 
});    
        response.type('text/xml');
        response.send(twiml.toString(''));
        });
        app.listen();

没有成功,因为下面的代码不在query.first函数中

twiml.dial({callerId:'twilioNumber'}, receiver);
                response.type('text/xml');

所以正确的做法是

//Someone calling twilio number
        app.get('/hello', function(request, response) {
        var twiml = new twilio.TwimlResponse('');

var query = new Parse.Query(Parse.User);
  query.equalTo("PhoneNumber", request.param('From'));
    query.first({
            success: function(result) {
            var foundusr = result;
            var receiver = foundusr.get("Receiver");
            twiml.dial({callerId:'twilioNumber'}, receiver);
            response.type('text/xml');
        response.send(twiml.toString(''));
},
            error: function(error) {response.error("Error updating user passcode"); 
});    

        });
        app.listen();