Twillio约会系统解析

问题描述:

我想让Twilio与我们的解析服务器集成,我知道如何发送消息给人,但我感到困惑的是你如何处理对解析服务器的响应。我需要使用传入号码来处理(仅一次)更改Parse中的字段。Twillio约会系统解析

我该如何处理我的服务器?

Twilio开发者传道这里。

当有人向您提供的URL发送SMS消息到您的Twilio号码Twilio will make an HTTP request。您可以在编辑your phone numbers之一时设置该URL。然后您需要创建一个可处理该传入HTTP请求的应用程序。据我所知,解析服务器是基于Express的。所以你可以关注this guide which takes you through setting up a server to receive and then reply to an incoming SMS message with Node.js and Express

更具体地来分析,如果从语法分析服务器项目中使用的示例代码,你需要做的是这样的:

var express = require('express'); 
var ParseServer = require('parse-server').ParseServer; 
var app = express(); 

var api = new ParseServer({ 
    databaseURI: 'mongodb://localhost:27017/dev', // Connection string for your MongoDB database 
    cloud: '/home/myApp/cloud/main.js', // Absolute path to your Cloud Code 
    appId: 'myAppId', 
    masterKey: 'myMasterKey', // Keep this key secret! 
    fileKey: 'optionalFileKey', 
    serverURL: 'http://localhost:1337/parse' // Don't forget to change to https if needed 
}); 

// Serve the Parse API on the /parse URL prefix 
app.use('/parse', api); 

// Receive incoming Twilio SMS messages 
app.post('/messages', function(req, res) { 
    console.log(req.body.Body); 
    // do something 
    // send an empty response to Twilio 
    res.send("<Response />"); 
}); 

app.listen(1337, function() { 
    console.log('parse-server-example running on port 1337.'); 
}); 

让我知道,如果这有助于在所有。

+0

是的,这确实有帮助!调用云计算函数还是仅仅实际执行我需要在同一个地方执行的内容,以便声明app.post会更容易些?只考虑组织和清晰点。 我会基本上只使用JavaScript SDK进行解析来执行我需要执行的操作吗? – trever

+0

哦,呃,我不确定如何最好地布置一个Parse应用程序,如果你想保持它作为一个云功能,那么它可以工作,或者你可以使用普通的Express方法。这取决于您如何组织代码的其余部分。 – philnash