Skip to content

Instantly share code, notes, and snippets.

@emilstahl
Last active January 4, 2016 05:49
Show Gist options
  • Save emilstahl/8577967 to your computer and use it in GitHub Desktop.
Save emilstahl/8577967 to your computer and use it in GitHub Desktop.
Send Twillio SMS command line promoting for name, number and message.
<?php
// Step 1: Download the Twilio-PHP library from twilio.com/docs/libraries,
// and move it into the folder containing this file.
require "Services/Twilio.php";
// Step 2: set our AccountSid and AuthToken from www.twilio.com/user/account
$accountSid = 'xx';
$authToken = 'yy';
// Step 3: instantiate a new Twilio Rest Client
$client = new Services_Twilio($accountSid, $authToken);
$number = readline("Number: ");
$message = readline("Message: ");
$sms = $client->account->messages->sendMessage(
// Step 6: Change the 'From' number below to be a valid Twilio number
// that you've purchased, or the (deprecated) Sandbox number
"zz", $number, $message
);
// Display a confirmation message on the screen
echo "Message sent to $number\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment