Speed up development with full-stack environments for every branch.

Learn More

Send an SMS using Twilio [PHP]

313 Runs 6908 Views 2811 Copies

Uses the Twilio API to send a text message to a cellphone. The phone number specified in the "TO_NUMBER" field will be sent the text message.



sundip 66

published 4 years ago

// Install the library via PEAR or download the .zip file to your project folder.
// This line loads the library

$sid = getenv("SID"); // Your Account SID from www.twilio.com/user/account
$token = getenv("TOKEN"); // Your Auth Token from www.twilio.com/user/account

$client = new Services_Twilio($sid, $token);
$message = $client->account->messages->sendMessage(
  getenv("TWILIO_NUMBER"), // From a valid Twilio number
  getenv("TO_NUMBER"), // Text this number
  "Hello from Runnable!"

print $message->sid;
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).