public function testPlayConvienceMethod() { $r = new Services_Twilio_Twiml(); $r->play("hello-monkey.mp3", array("loop" => 3)); $expected = '<Response><Play loop="3">' . 'hello-monkey.mp3</Play></Response>'; $this->assertXmlStringEqualsXmlString($expected, $r); }
private function generateVoiceFile(&$file_id, &$group_id) { $file = $this->fm->find($file_id)->name; $group = $this->gm->find($group_id)->name; $url = base_url() . 'uploads/voice/' . $file; $response = new Services_Twilio_Twiml(); $response->say('Hello'); $response->play($url, array("loop" => 0)); //generated file $twiML = 'uploads/xml/' . $group . '_' . time() . '.xml'; $xml = fopen($twiML, 'w'); fwrite($xml, $response); fclose($xml); return base_url() . $twiML; }
<?php /** * ミニコールセンターサービスでキューイング時にメッセージを送出するwait.php * * @author rutoru * @package Twilio-MiniCC * @GitHub https://github.com/rutoru/Twilio-MiniCC */ // 設定クラス require_once 'Conf.php'; // Twilio Helperライブラリ(index.phpと同じ場所にServicesフォルダが存在する前提) require_once 'Services/Twilio.php'; // Twimlオブジェクト作成 $response = new Services_Twilio_Twiml(); // QueuePosition取得(数字のみにフィルタリング) $waitnumber = filter_input(INPUT_POST, 'QueuePosition', FILTER_SANITIZE_NUMBER_INT); // 待ち(短めの保留音を入れる予定) $response->pause('3'); // キューイングメッセージ送出 $response->say("お待たせしております。現在、" . $waitnumber . "番目にお待ちです。", array('language' => Conf::LANG)); // 保留音送出 $response->play(Conf::MOH_LONG); // TwiML作成 print $response;
<?php require 'twilio-php-master/Services/Twilio.php'; $response = new Services_Twilio_Twiml(); $response->say('Liz Holzman'); $response->play('https://api.twilio.com/cowbell.mp3', array("loop" => 5)); print $response;
<?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;
} // Get config values $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');
/** * generateTwiML - Generates TwiML with passed text and music from url * * @param string $text - call message text * @param string|null $musicUrl - music url * @return string - generated XML * */ public function generateTwiML($text, $musicUrl = null, $musicOptions = array()) { $response = new Services_Twilio_Twiml(); $response->say($text); if (!empty($musicUrl)) { $response->play($musicUrl, $musicOptions); } return $response->__toString(); }
<?php require 'vendor/twilio/sdk/Services/Twilio.php'; $response = new Services_Twilio_Twiml(); $response->play('https://api.twilio.com/cowbell.mp3'); print $response;