bio photo

Email

####Intro

Alot of time spent hacking and attempting to reverse engineer the code in this tutorial(controling a servo motor with SMS via Twilio). I did a p_comp Node.JS lab and decided to start hacking on Twilio’s documentation in particular its compatibility with Node.js.

####The test worked!

Code below. Next step, getting it to work alongside Arduino Serialport library.

To note:

I should be able to alter JSON values in Twilios code (client.sendMessage.to and client.sendMessage.body) to alter phone number and SMS content which a user can set from the browser.

//require the Twilio module and create a REST client
var client = require('twilio')('<--[removed]-->', '<--[removed]-->');

//Send an SMS text message
client.sendMessage({

    to:'+17185701757', // Any number Twilio can deliver to
    from: '+17182159247', // A number you bought from Twilio and can use for outbound communication
    body: 'Hello Osama - this is a test message.' // body of the SMS message

}, function(err, responseData) { //this function is executed when a response is received from Twilio

    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 "+14506667788"
        console.log(responseData.body); // outputs "word to your mother."

    }
});

####