Site icon Web Niraj

Twilio API: Sending a Text Message

I’ve been experimenting with the Twilio API recently and have found it very easy to automatically send text messages or call a telephone programmatically. In fact, you are able to send a text message in just a few lines of code. Such a service can use used to validate mobile phone numbers for an app, much like how Facebook does.

Using the Twilio PHP library, sending a message can be achieved in a few lines of code.

See the gist on github.

The above 12 lines of code is enough to send a simple message to any mobile phone. Making a phone is even easier, and I’ll cover that in a later post.

Twilio doesn’t have a JavaScript SDK, unfortunately, so you would have to create a server-side API (using PHP) and then use JavaScript (with jsonp) to call the API. This again is quite straight forward to do in JavaScript, but requires more coding on the back-end (PHP) to secure the script.

Exit mobile version