Skip to content

Instantly share code, notes, and snippets.

@RobSpectre
Created June 24, 2012 19:12
Show Gist options
  • Save RobSpectre/2984521 to your computer and use it in GitHub Desktop.
Save RobSpectre/2984521 to your computer and use it in GitHub Desktop.
Get SMS notifications when user calls the number on your website
<?php
header('Content-type: text/xml');
// Set your account credentials and numbers you want to call and text.
$ACCOUNT_SID = "ACxxxxxxxxx";
$AUTH_TOKEN = "yyyyyyyyyyyy";
$TWILIO_NUMBER = "+12223334444";
$NUMBER_TO_CALL = "+15556667777";
$NUMBER_TO_TEXT = "+15554443333";
// Import Twilio PHP helper library
require_once('Services/Twilio.php');
// Get identifying information from call.
$from = $_REQUEST['From'];
$from_city = $_REQUEST['FromCity'];
$from_state = $_REQUEST['FromState'];
// Send text messages notifying site owner of inbound lead.
$client = new Services_Twilio($ACCOUNT_SID, $AUTH_TOKEN);
$message = $client->account->sms_messages->create(
$TWILIO_NUMBER,
$NUMBER_TO_TEXT,
"You got a call from: ".$from.", ".$from_city.", ".$from_state
);
// Connect website lead to employee who can answer their call.
?>
<Response>
<Dial><Number><?php echo $NUMBER_TO_CALL; ?></Number></Dial>
</Response>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment