There I'm Using Twillio Example api
// Step 1: Get the Twilio-PHP library from twilio.com/docs/libraries/php,
// and move it into the folder containing this sendnotifications.php file.
require "Services/Twilio.php";
// Step 2: set our AccountSid and AuthToken from https://twilio.com/console
$AccountSid = "ACea465f2e60ae87332cf47adb0e4aad64";
$AuthToken = "your_auth_token";
// Step 3: instantiate a new Twilio Rest Client
$client = new Services_Twilio($AccountSid, $AuthToken);
// Step 4: make an array of people we know, to send them a message.
// Feel free to change/add your own phone number and name here.
$people = array(
"+15558675309" => "Curious George",
"+15558675308" => "Boots",
"+15558675307" => "Virgil",
);
// Step 5: Loop over all our friends. $number is a phone number above, and
// $name is the name next to it
foreach ($people as $number => $name) {
$sms = $client->account->messages->sendMessage(
// Step 6: Change the 'From' number below to be a valid Twilio number
// that you've purchased
"+15017250604",
// the number we are sending to - Any phone number
$number,
// the sms body
"Hey $name, Monkey Party at 6PM. Bring Bananas!"
);
// Display a confirmation message on the screen
echo "Sent message to $name";
}
and here is my code
// Step 1: Get the Twilio-PHP library from twilio.com/docs/libraries/php,
// and move it into the folder containing this sendnotifications.php file.
require "Services/Twilio.php";
// Step 2: set our AccountSid and AuthToken from https://twilio.com/console
$AccountSid = "accountsid";
$AuthToken = "authtoken";
// Step 3: instantiate a new Twilio Rest Client
$client = new Services_Twilio($AccountSid, $AuthToken);
// Step 4: make an array of people we know, to send them a message.
// Feel free to change/add your own phone number and name here.
$people = array(
"my-number-goes-here" => "Ali M. Ayad",
);
// Step 5: Loop over all our friends. $number is a phone number above, and
// $name is the name next to it
foreach ($people as $number => $name) {
$sms = $client->account->messages->sendMessage(
// Step 6: Change the 'From' number below to be a valid Twilio number
// that you've purchased
"+13862593325",
// the number we are sending to - Any phone number
$number,
// the sms body
"Hey Ali This is test message form the api"
);
// Display a confirmation message on the screen
echo "Sent message to $name";
}
when i put this code and i change the auth and id and the number is give my this message
Fatal error: Uncaught exception 'Services_Twilio_RestException' with message 'Authentication Error - invalid username' in C:\AppServ\www\tw\Services\Twilio.php:297 Stack trace: #0 C:\AppServ\www\tw\Services\Twilio.php(180): Base_Services_Twilio->_processResponse(Array) #1 C:\AppServ\www\tw\Services\Twilio\ListResource.php(92): Base_Services_Twilio->createData('/2010-04-01/Acc...', Array) #2 C:\AppServ\www\tw\Services\Twilio\Rest\Messages.php(24): Services_Twilio_ListResource->_create(Array) #3 C:\AppServ\www\tw\Services\Twilio\Rest\Messages.php(71): Services_Twilio_Rest_Messages->create(Array) #4 C:\AppServ\www\tw\sendnotifications.php(48): Services_Twilio_Rest_Messages->sendMessage('+13862593325', '+201063378955', 'Hey Ali This is...') #5 {main} thrown in C:\AppServ\www\tw\Services\Twilio.php on line 297 i'm using appserv
AuthToken&AccoundSidin that you can get from your dashboard? - Darren