我想实现短信验证,我想知道如何使用 Meteor 向给定的电话号码发送短信?
最佳答案
我已经能够使用从 meteor-twilio 构建的 node library 包来做到这一点(您需要一个 Twilio 帐户)。该包导出一个名为 Twilio 的全局变量,您可以像这样使用它:
// server-side code
...
var twilio = Twilio(accountSid, authToken);
this.unblock(); // make the request asynchronously
twilio.sendSms({
to:'+445678984', // any number Twilio can deliver to
from: '+12125551212', // must be your Twilio account phone number
body: 'here is your confirmation'
}, function(err, responseData) { //executed when a response is received from Twilio
if (!err) {
// "responseData" is a JavaScript object containing data received from Twilio.
console.log(responseData.body); // outputs "here is your confirmaton"
}
...
这可以在 Meteor.method
调用中完成。
关于javascript - Meteor Js + 短信验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20803103/