When you buy an SMS-enabled Twilio phone number, you can associate that phone number with a URL. When someone sends a text message to that phone number, Twilio makes an HTTP request to your URL with the body of the message and the sender’s phone number. You can then respond to the Message by returning a reply message in the HTTP response to Twilio.

You can also send messages using Twilio’s REST API. To send a message, just make an HTTP POST to Twilio with the body of the message and the phone number you want to send it to. SMS messages must be sent from Twilio SMS-enabled phone numbers due to the architecture of the global SMS network.

You can use the following code for sending message through twilio api,For that you need to download the twilio library from twilio.com/docs/libraries.

/* Send an SMS using Twilio. You can run this file 3 different ways:
* – Save it as sendnotifications.php and at the command line, run
* php sendnotifications.php
* – Upload it to a web host and load mywebhost.com/sendnotifications.php
* in a web browser.
* – Download a local server like WAMP, MAMP or XAMPP. Point the web root
* directory to the folder containing this file, and load
* localhost:8888/sendnotifications.php in a web browser.
// Step 1: Download the Twilio-PHP library from twilio.com/docs/libraries,
// and move it into the folder containing this file.
require “Services/Twilio.php”
// Step 2: set our AccountSid and AuthToken from www.twilio.com/user/account
// Step 3: instantiate a new Twilio Rest Client
$client = new Services_Twilio($AccountSid, $AuthToken)
// Step 4: make an array of people we know, to send them a message.
// Feel free to change/add your own phone number and name here.
$people = array(
“phone number with country code” => “Name”,
“phone number with country code” => “Name”,
“phone number with country code” => “Name”,
// Step 5: Loop over all our friends. $number is a phone number above, and
// $name is the name next to it
foreach ($people as $number => $name) {
$sms = $client->account->messages->sendMessage(
// Step 6: Change the ‘From’ number below to be a valid Twilio number
// that you’ve purchased, or the (deprecated) Sandbox number
// the number we are sending to – Any phone number
// the sms body
“Hey $name, Test message”
// Display a confirmation message on the screen
echo “Sent message to $name”