Showing posts with label Twilio API. Show all posts
Showing posts with label Twilio API. Show all posts

Wednesday, April 30, 2014

Send SMS PHP Integration Using Twilio API

This sample source code is a simple PHP Integration which uses Twilio API.

Get Your API ACCOUNT SID and AUTH TOKEN 
http://www.twilio.com/user/account/

Source Code
<?php

   require_once 'Services/Twilio.php';

   define('ACCOUNT_SID', '<YOUR-ACCOUNT-SID>');  
   define('AUTH_TOKEN', '<YOUR-AUTH-TOKEN>');  
   
   $client = new Services_Twilio(ACCOUNT_SID, AUTH_TOKEN);
   
   /* Send an SMS */
   
   $twilioNumber = "XXX-XXX-XXXX";  /* Twilio number that you've purchased*/
   $mobilePhoneNumber = "+63XXXXXXXXXXX"; /* the number you are sending */
   
   $artist = "Juan Dela Cruz";
   $message = "Rock N Roll!. - {$artist}";
   
   $sendSMS = $client->account->sms_messages->create($twilioNumber , $mobilePhoneNumber , $message );
   
   /* Response */
   echo $sendSMS->sid;
   
  
?>
   

Genesis Framework for WordPress