yozawiratama yozawiratama - 1 year ago 134
Javascript Question

Meteor Js + sms verification

I'd like to implement a sms verification and I wonder how I can send sms to a given phone number by using Meteor?

Answer Source

I've been able to do this using the meteor-twilio package built from the node library (you'd need a Twilio account). The package exports a global called Twilio that you can use like this:

    // server-side code
    var twilio = Twilio(accountSid, authToken);
    this.unblock(); // make the request asynchronously
      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"

This can be done inside a Meteor.method call.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download