我正在基本的流星应用程序中实现Twilio的实现。我已经设置了客户端代码来调用下面的服务器端方法(在这种情况下,登录时)。
调用该方法时没有问题,并且服务器日志中不会产生错误。但是,如果我注销我的响应数据,则它是未定义的。这是时间问题吗?我的印象是,在收到回复时会调用包含响应或错误的函数。
任何意见都会受到赞赏,提前谢谢!
Meteor.methods({
twilioTest:function () {
console.log("Twilio Test Called!");
ACCOUNT_SID = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";
AUTH_TOKEN = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";
twilio = Twilio(ACCOUNT_SID, AUTH_TOKEN);
twilio.sendSms({
to:'+xxx-xxx-xxxx', // Any number Twilio can deliver to
from: '+xxx-xxx-xxxx', // A number you bought from Twilio and can use for outbound communication
body: 'Greetings!' // body of the SMS message
},function(err, responseData) { //this function is executed when a response is received from Twilio
console.log(responseData); // log out response object
if (!err) { // "err" is an error received during the request, if any
// "responseData" is a JavaScript object containing data received from Twilio.
// A sample response from sending an SMS message is here (click "JSON" to see how the data appears in JavaScript):
// http://www.twilio.com/docs/api/rest/sending-sms#example-1
console.log(responseData.from); // outputs outbound number
console.log(responseData.body); // outputs message body
}
});
}