Created
June 25, 2013 03:28
-
-
Save hunnycode/5855708 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-type: text/xml'); | |
// put a phone number you've verified with Twilio to use as a caller ID number | |
$callerId = "<発信番号>"; | |
// put your default Twilio Client name here, for when a phone number isn't given | |
$number = "jenny"; | |
// get the phone number from the page request parameters, if given | |
if (isset($_REQUEST['PhoneNumber'])) { | |
$number = htmlspecialchars($_REQUEST['PhoneNumber']); | |
} | |
// wrap the phone number or client name in the appropriate TwiML verb | |
// by checking if the number given has only digits and format symbols | |
if (preg_match("/^[\d\+\-\(\) ]+$/", $number)) { | |
$numberOrClient = "<Number>" . $number . "</Number>"; | |
} else { | |
$numberOrClient = "<Client>" . $number . "</Client>"; | |
} | |
?> | |
<Response> | |
<Dial callerId="<?php echo $callerId ?>"> | |
<?php echo $numberOrClient ?> | |
</Dial> | |
</Response> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment