public function index(Application $app, Request $request) { $twiml = new \Services_Twilio_Twiml(); $gather = $twiml->gather(array('action' => 'http://' . $app['request']->getHost() . $app['url_generator']->generate('twilio_poll_process'), 'method' => 'GET', 'timeout' => '30', 'numDigits' => '1')); $gather->say("これから投票を行います。1桁の作品番号を押してください。", array('language' => 'ja-jp')); $xml = strval($twiml); $response = new Response($app['twig']->render('TwilioPoll/Resource/template/xml.twig', array('xml' => $xml)), 200, array('Content-Type' => 'text/xml')); return $response; }
<?php require_once 'vendor/autoload.php'; $response = new Services_Twilio_Twiml(); $gather = $response->gather(array('action' => 'http://' . $_SERVER['SERVER_NAME'] . '/process_needs.php', 'method' => 'GET', 'timeout' => '30', 'numDigits' => '1')); $gather->say("お電話ありがとうございます。こちらは豊島区被災者ニーズ申請サービスです。着るもので困っている場合は1を、食べるもので困っている場合は2を、住むところで困っている場合は3を、病気で困っている場合は4を、帰宅が困難になっている人は5を押してください", array('language' => 'ja-jp')); header("Content-type: text/xml"); print $response;
public function poll($randomnum, $sch_id) { $this->load->model(array('reply_status_model')); $response = new Services_Twilio_Twiml(); $gather = $response->gather(array('action' => base_url() . 'index.php/admin/staff_call/process_poll/' . $randomnum . '/' . $sch_id, 'method' => 'GET', 'numDigits' => '1')); $reply_items = array(); $reply_rows = $this->reply_status_model->get_rows(array()); $gather->say("Attendance status call."); $gather->say("Shift is started already. "); foreach ($reply_rows as $reply_row) { if ($reply_row->number > 0) { $gather->say("Press " . $reply_row->number . ' for ' . $reply_row->title . '. '); $gather->pause('1'); //$reply_items[] = '('.$reply_row->number.')'.$reply_row->title; } } header('Content-Type: text/xml'); print $response; }
$pagerduty = new \Vend\Phoneduty\Pagerduty($APItoken, $serviceAPItoken, $domain); $userID = $pagerduty->getOncallUserForSchedule($scheduleID); $user = $pagerduty->getUserDetails($userID); $twilio = new Services_Twilio_Twiml(); $attributes = array('voice' => 'alice', 'language' => $language); if (isset($_POST['Digits'])) { if ($_POST['Digits'] != '') { $_SESSION['end_user_confirmed_call'] = True; } } if (!isset($_SESSION['end_user_confirmed_call']) and strtolower($validate_human) == 'true') { if ($greeting != '') { $twilio->say($greeting, $attributes); $_SESSION['caller_greeted'] = True; } $gather = $twilio->gather(array('timeout' => 25, 'numDigits' => 1)); $gather->say("Press 1 to reach the on-call engineer.", $attributes); $twilio->say("Goodbye.", $attributes); $twilio->hangup(); } else { if ($greeting != '') { if (!isset($_SESSION['caller_greeted'])) { $twilio->say($greeting, $attributes); $_SESSION['caller_greeted'] = True; } } if ($user !== null) { $time = ""; if ($announceTime == strtolower("true") && $user['local_time']) { $time = sprintf(" The current time in their timezone is %s.", $user['local_time']->format('g:ia')); }
<?php require "Services/Twilio.php"; $response = new Services_Twilio_Twiml(); $out_tel_to = "転送先電話番号"; $sound_url_s1 = "一段目に水をはって火にかける。フラワーウォータの出来上がり!.mp3"; if (empty($_POST["Digits"])) { $gather = $response->gather(array('numDigits' => 1, 'timeout' => 30)); $gather->say("Twilioへようこそ。モロッコのお母さんのレシピが知りたい方は1を。電話の転送は2を。社会人3年目の方は3を。電話の終了は4をおしてください。", array('language' => 'ja-jp')); } elseif ($_POST["Digits"] == "1") { $response->play($sound_url, array("loop" => 1)); $gather = $response->gather(array('numDigits' => 1, 'timeout' => 30)); } elseif ($_POST["Digits"] == "2") { $response->dial($out_tel_to); $gather = $response->gather(array('numDigits' => 1, 'timeout' => 30)); } elseif ($_POST["Digits"] == "3") { $response->say("社会人3年目の方、楽しいデモへようこそ。", array('language' => 'ja-jp')); } elseif ($_POST["Digits"] == "4") { $response->say("楽しいデモのご利用ありがとうございました。", array('language' => 'ja-jp')); } print $response;
include 'company-directory-map.php'; $error = false; if (isset($_REQUEST['Digits'])) { $digits = $_REQUEST['Digits']; } else { $digits = ''; } if (strlen($digits)) { $result = getPhoneNumberByDigits($digits); if ($result != false) { $number = getPhoneNumberByExtension($result['extension']); $r = new Services_Twilio_Twiml(); $r->say($result['name'] . "'s extension is " . $result['extension'] . " Connecting you now"); $r->dial($number); header("Content-Type:text/xml"); print $r; exit; } else { $error = true; } } $r = new Services_Twilio_Twiml(); if ($error) { $r->say("No match found for {$digits}"); } $g = $r->gather(); $g->say("Enter the first several digits of the last name of the party you wish to reach, followed by the pound sign"); $r->say("I did not receive a response from you"); $r->redirect("company-directory.php"); header("Content-Type:text/xml"); print $r;
function testGeneration() { $r = new Services_Twilio_Twiml(); $r->say('hello'); $r->dial()->number('123', array('sendDigits' => '456')); $r->gather(array('timeout' => 15)); $doc = simplexml_load_string($r); $this->assertEquals('Response', $doc->getName()); $this->assertEquals('hello', (string) $doc->Say); $this->assertEquals('456', (string) $doc->Dial->Number['sendDigits']); $this->assertEquals('123', (string) $doc->Dial->Number); $this->assertEquals('15', (string) $doc->Gather['timeout']); }
$config = array(); $d = select_query('mod_twilio_config', '*', array()); while ($res = mysql_fetch_assoc($d)) { $setting = $res['setting']; $value = $res['val']; $config[$setting] = $value; } $resp = new Services_Twilio_Twiml(); if (!isset($_REQUEST['step'])) { $resp = new Services_Twilio_Twiml(); if ($config['intro_mode'] == 'text') { $resp->say($config['intro_text']); } else { $resp->play('get_audio.php?f=intro_file'); } $gather = $resp->gather(array('timeout' => $config['gather_timeout'], 'numDigits' => '1', 'action' => 'call_handler.php?step=1')); if ($config['invalid_request_mode'] == 'text') { $resp->say($config['invalid_request_text']); } else { $resp->play('get_audio.php?f=invalid_request_file'); } $resp->redirect('call_handler.php'); } elseif ($_REQUEST['step'] == '1') { if ($_REQUEST['Digits'] == '1') { $_SESSION['type'] = 'ticket'; if ($config['step1_ticket_mode'] == 'text') { $resp->say($config['step1_ticket_text']); } else { $resp->play('get_audio.php?f=step1_ticket_file'); } $gather = $resp->gather(array('timeout' => $config['gather_timeout'], 'finishOnKey' => '#', 'action' => 'call_handler.php?step=2'));
<?php require '../twilio-twilio-php/Services/Twilio.php'; $response = new Services_Twilio_Twiml(); $gather = $response->gather(array( 'action' => 'http://ec2-50-19-182-194.compute-1.amazonaws.com/partyPlanner/phonepoll/process_poll.php?answer1='.urlencode($_GET['answer1']).'&answer2='.urlencode($_GET['answer2']).'&answer3='.urlencode($_GET['answer3']), 'method' => 'GET', 'numDigits' => '1' )); $gather->say("Hi, your friend ".urldecode($_GET['friend_name'])." wants you to know about their ".urldecode($_GET['event_name']).". "); $gather->say(". ".urldecode($_GET['question'])); $gather->say("1 for ".urldecode($_GET['answer1'])); $gather->say("2 for ".urldecode($_GET['answer2'])); $gather->say("3 for ".urldecode($_GET['answer3'])); header('Content-Type: text/xml'); print $response;
switch ($input) { case '1': // 1の場合はオペレータに接続 $response->say('オペレータにおつなぎします。しばらくお待ちください。', array('language' => Conf::LANG)); // Queueに入れる // 待ちが発生した場合は、waitUrl呼び出し $response->enqueue(Conf::QUEUE, array('waitUrl' => 'wait.php', 'action' => $enqueue_action_url, 'method' => Conf::METHOD)); break; case '2': // 2の場合は情報を提供する // XMLファイル呼び出し $response->redirect('information.xml'); break; default: // 1,2以外の場合は再入力 $gather = $response->gather(array('numDigits' => 1, 'timeout' => '10', 'method' => 'POST')); $gather->say('再度入力をお願いします。' . 'お問い合わせは1を、' . '最新の製品情報をお聞きになりたい場合は2を押してください。', array('language' => Conf::LANG)); // タイムアウトとなった場合はオペレータに接続 $response->say('入力が確認できませんでした。オペレータにおつなぎします。しばらくお待ちください。', array('language' => Conf::LANG)); $response->enqueue(Conf::QUEUE, array('waitUrl' => 'wait.php', 'action' => $enqueue_action_url, 'method' => Conf::METHOD)); break; } } else { try { // 発信電話番号を取得し、DB照会 $db = new Database(); $stmt = $db->getPdo()->prepare('SELECT telnum FROM operators WHERE telnum = :ani'); $stmt->bindValue(':ani', filter_input(INPUT_POST, 'From')); $stmt->execute(); // 発信者がオペレータだった場合 if ($stmt->rowCount()) {
break; } break; case "notice": // アラート通知 $log->info("自動通知処理開始"); // URLデコード $message = urldecode($_REQUEST['message']); // $$MESSAGE$$ $message = str_replace('$$MESSAGE$$', $message, $MESSAGE_NOTICE); // $$DIGITS$$を置き換え $message = str_replace('$$DIGITS$$', $DIGITS, $message); $log->debug("MESSAGE:{$message}"); $log->debug("DIGITS_TIMEOUT:{$DIGITS_TIMEOUT} DIGITS_NUM:{$DIGITS_NUM} URL:{$SCRIPT_URL}"); $response = new Services_Twilio_Twiml(); $gather = $response->gather(array('action' => $SCRIPT_URL . '?cmd=register&eventid=' . $_REQUEST['eventid'] . '&name=' . $_REQUEST['name'], 'timeout' => $DIGITS_TIMEOUT, 'finishOnKey' => '#', 'numDigits' => $DIGITS_NUM)); $gather->say($message, array('voice' => 'woman', 'language' => 'ja-JP')); header('Content-type: text/xml'); print $response; $log->debug($response); break; default: } exit; // ****************************************************************** // *** Zabbix_API *** // ****************************************************************** class Zabbix_API { private $api_url = ''; private $auth = '';