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
Leave a Reply