I am looking at Twilio API right now for a project and I am surprised how easy is to handle voice and SMS messages. Here is an example, written by me:

ApiVersion = "2008-08-01";
	$this->AccountSid = "Axxxxxxxxxxxxxxxxxxxx"; //get your own after trial registration on Twilio.com
	$this->AuthToken = "axxxxxxxxxxxxxxxxxxxxx";
	$this->smsServer = new TwilioRestClient($this->AccountSid, $this->AuthToken);
}

function sendSMS($to, $from, $whattosend)
{

	$response = $this->smsServer->request("/$this->ApiVersion/Accounts/$this->AccountSid/SMS/Messages", 
			"POST", array(
			"To" => $to,
			"From" => $from,
			"Body" => $whattosend
		));
		if($response->IsError)
			echo "Error: {$response->ErrorMessage}";
		else
			echo "Done";



}


function __destruct()
{

	unset($this->ApiVersion);
	unset($this->AccountSid);
	unset($this->AuthToken); 
        
}

}


$s= new Twillio_SMS;
$s->sendSMS('4155992671','4155992671','this is a test');

?>

GitHub
If you are interested in this topic, or if you have some ideas, please join me at my test repo @ Github

2 thoughts on “Sending SMS messages via Twilio Rest API

  1. Does this code like this let a website visitor join an sms subscription list? We built an SMS application using twilio’s API and I would like for visitors to join one of my lists from a website by entering their phone # and sending it to my application somehow.

  2. We have specialised packages for various industries including Automobile Industry, Share Traders, Schools / Colleges, Events & Exhibitors and can design customised applications. Our APIs help you in automating the process of sending personal customized SMS through your web applications in PHP, ASP, Asp.net or VB. Get in touch with our Live Customer Support and we will help you out with a solution.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.