Sending SMS from PC to Mobile

By on Aug 12, 2014 in Intermediate

Share On GoogleShare On FacebookShare On Twitter

Sending SMS from PC to Mobile
Sending SMS from PC to Mobile is very easy. This simple tutorial will guide you thought the basic steps to start Sending SMS from your computer to a Mobile device. The first thing you will need to to find an SMS Gateway. For this tutorial I will be using Twilio, a cloud communications company based in San Francisco, California.

Start Sending SMS from PC to Mobile

Step 1:

Sign-up for Twilio. Right of the batch you get a free number and some testing minutes. However, every time you send an SMS or place a call they will play their disclaimer saying that this is a demo account. So if you want to get rid of this message you can go ahead and purchase a number. They are pretty cheap usually 1 dollar a month, and this number you can use for many things not just sending SMS You can use this number for placing and receiving calls. For more information on how to do this check out this tutorial Making phone calls from your computer. I will also advice you to buy some credit, again it is pretty cheap, they only charge $0.01 per minutes for phone calls and $0.0075 per SMS message.

Step 2:

Now that you have your number and some credit in your account is when all the fun begins. For this tutorial we will be using server-side javascript to send our SMS. We will be doing this by using node js. Note that you can use other languages as Twilio has a great variety of SDKs for PHP, Ruby .Net and many others. For more information about node js and how to get started with node js check out this simple tutorial.

Let go ahead and create a new directory where we will be developing our simple Sending SMS from PC to Mobile application. Lets call this directory “twilio-sms-tutorial”

Now we need to download the twilio SDK into this directory so we can interact with the twilio API. Open your terminal and cd into this newly created directory. Go ahead and type:
[sudo] npm install twilio

node js has a simple module loading system which looks for modules in a “node_modules” directory in the path where the node program is run. After installing the Twilio module from npm using the method above, you will notice a “node_modules” directory in your demo folder, and that the twilio module is inside it.

Step 3

Now it is time to write some code. With the Twilio SDK you get a lot of features that will eventually come in handy as you start exploring their API more and more. The Twilio module provides three main functional areas:

For this tutorial we will be using the REST API to send an SMS from PC to Mobile. You will need to cope and paste your Authentication parameters from Twilio. That is your Auth. Token and your Account SID. You can get this information by logging in t your Twilio account https://www.twilio.com/user/account.

Once you have those Auth. Params ready go ahead and create a new file inside the “twilio-sms-tutorial” directory and call it send-sms.js.


// Load twilio SDK
var twilio = require('twilio');
// Create a new client 
var client = new twilio.RestClient('YOUR_TWILIO_ACCOUNT_SID', 'YOUR_TWILIO_AUTH_TOKEN');
// Pass in parameters to the REST API using an object literal notation. The
// REST client will handle authentication and response serialzation for you.
    body:'Hello World! This is a sample SMS message powered by Twilio'
}, function(error, message) {
    // The HTTP request to Twilio will run asynchronously. This callback
    // function will be called when a response is received from Twilio
    // The "error" variable will contain error information, if any.
    // If the request was successful, this value will be "falsy"
    if (!error) {
        // The second argument to the callback will contain the information
        // sent back by Twilio for the request. In this case, it is the
        // information about the text messsage you just sent:
        console.log('OK! SID for this SMS message:');
        console.log('Message sent on:');
    } else {
        console.log('Oops! There was an error.');

Now all you have to do is run send-sms.js. To do so all you have to do is type this in your console:
node send-sms.js. After a couple seconds you should see the information about the message being outputted on the console via the console.log message we specified on the code above.

And that’s how you send SMS from your personal computer to any mobile device. Hope you found this tutorial helpful, please remember to comment bellow with any questions or suggestions you might have. Thanks!

Enmanuel Corvo
Latest posts by Enmanuel Corvo (see all)
468 ad