Skip to content

Instantly share code, notes, and snippets.

@twilioforkwc
Last active September 23, 2015 01:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twilioforkwc/2f223556da0cee85bbf2 to your computer and use it in GitHub Desktop.
Save twilioforkwc/2f223556da0cee85bbf2 to your computer and use it in GitHub Desktop.
<?php
require('Services/Twilio.php');
$number = "hoge";
// 画面から入力された電話番号の取得
if (isset($_REQUEST['To'])) {
$number = $_REQUEST['To'];
}
// 発信先が番号かClient名かを判別し、発信先を設定する。
if (preg_match("/^[\d\+\-\(\) ]+$/", $number)) {
$numberOrClient = "<Number>" . $number . "</Number>";
} elseif(stristr($number, "@")) {
$numberOrClient = "<Sip>" . $number . "</Sip>";
} else {
$numberOrClient = "<Client>" . $number . "</Client>";
}
?>
<Response>
<Say language="ja-jp">Twilio Clientから電話をかけます。</Say>
<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