我想使用Twilio and Nodejs开发会议应用程序。 在我的申请中,第一个人在接到电话的第一个人需要创建会议并打电话给另一个人加入同一个会议室之后接到来自twilio号码的电话。我创建了以下代码,但它无法正常工作。
app.post('/callcenter', function(req, res) {
var twiml = new twilio.TwimlResponse();
client.makeCall({
to : config.twilio.to, // Any number Twilio can call
from : config.twilio.from, // A number you bought from Twilio and can use for outbound communication
url : 'http://example.com/createconf' // A URL that produces an XML document (TwiML) which contains instructions for the call
}, function(err, responseData) {
console.log(responseData.from); // outputs "+14506667788"
if (err) {
response.status(500).send(err);
} else {
res.type('text/xml');
res.send(twiml.toString());
console.log(twiml.toString());
}
});
});
app.post('/createconf', function(req, res) {
var twiml = new twilio.TwimlResponse();
console.log('Inside createconf');
.gather({
action:'http://exampl.com/enterinconf',
finishOnKey:'*',
numDigits:'1',
timeout:'20'
}, function() {
this.say('Press 1 for moderator')
.say('Press 2 for speak');
})
res.type('text/xml');
res.send(twiml.toString());
console.log(twiml.toString());
});
app.post('/enterinconf', function(req, res) {
var twiml = new twilio.TwimlResponse();
client.makeCall({
to : config.twilio.modfwd, // Any number Twilio can call
from : config.twilio.from, // A number you bought from Twilio and can use for outbound communication
url : '../conference/moderatorconf.xml' // A URL that produces an XML document (TwiML) which contains instructions for the call
}, function(err, responseData) {
console.log(responseData.from);
if (err) {
response.status(500).send(err);
} else {
res.type('text/xml');
res.send(twiml.toString());
console.log(twiml.toString());
}
});
});
有人可以帮我解决这个问题,我可以用twilio在Nodejs中开发电话会议。