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

Learn More

Send an SMS using Twilio [PHP]

313 Runs 6625 Views 2542 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.

Saved

Saved

sundip 66

sundip
published 4 years ago

 <?php
// Install the library via PEAR or download the .zip file to your project folder.
// This line loads the library
require('twilio-php-master/Services/Twilio.php');

$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).