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;
   
  
?>
   

1 comment:

  1. Thanks for sharing. MsgClub brings SMS API PHP integration for sending bulk SMS to the prospective clients and also the existing customers. This is the best and one-stop solution to all your business marketing needs.

    ReplyDelete

Genesis Framework for WordPress