本文整理汇总了PHP中Response::addSpeak方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::addSpeak方法的具体用法?PHP Response::addSpeak怎么用?PHP Response::addSpeak使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Response
的用法示例。
在下文中一共展示了Response::addSpeak方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSpeakConvienceMethod
public function testSpeakConvienceMethod()
{
$r = new Response();
$r->addSpeak("Hello Monkey", array("language" => "fr"));
$expected = '<Response><Speak language="fr">Hello Monkey</Speak></Response>';
$this->assertXmlStringEqualsXmlString($expected, $r->asUrl(False));
}
示例2: array
<?php
require_once "./plivo.php";
$from_number = $_REQUEST['From'];
$callers = array('1111111111' => 'ABCDEF', '2222222222' => 'VWXYZ', '3333333333' => 'QWERTY');
$r = new Response();
if (array_key_exists($from_number, $caller)) {
$body = "Hello {$caller[$from_number]}";
$r->addSpeak($body);
} else {
$body = "Hello Stranger!";
$r->addSpeak($body);
}
Header('Content-type: text/xml');
echo $r->toXML();
/*
Sample Output
<Response>
<Speak>Hello,ABCDEF</Speak>
</Response>
*/
示例3: array
<?php
require_once "./plivo.php";
// Generate a Speak XML with the details of the text to play on the call.
$body = 'Hi, Calling from Plivo';
$attributes = array('loop' => 2);
$r = new Response();
// Add speak element
$r->addSpeak($body, $attributes);
Header('Content-type: text/xml');
echo $r->toXML();
/*
Sample Output
<Response>
<Speak loop="2">Hi, Calling from Plivo</Speak>
</Response>
*/
示例4: dirname
<?php
// Include the PHP Plivo Rest library
require "./plivohelper.php";
$base_http = "http://" . dirname($_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"]);
/* Render RESTXML */
$r = new Response();
$r->addSpeak('Hello world');
$r->addSpeak('${strepoch()}', array('loop' => 1, 'type' => "CURRENT_DATE_TIME", 'method' => "PRONOUNCED"));
$r->addSpeak('${strepoch()}', array('loop' => 5, 'type' => "CURRENT_TIME", 'method' => "PRONOUNCED"));
$r->Respond();
示例5: dirname
<?php
// Include the PHP Plivo Rest library
require "./plivohelper.php";
$base_http = "http://" . dirname($_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"]);
/* Render RESTXML */
$r = new Response();
if (isset($_POST['HangupCause']) && isset($_POST['RingStatus'])) {
$hangup_cause = $_POST['HangupCause'];
$ring_status = $_POST['RingStatus'];
$r->addSpeak("Dial Hangup Cause is " . $hangup_cause);
$r->addSpeak("Dial Ring Status is " . $ring_status);
$r->addSpeak("Dial Ended");
} else {
$r->addSpeak("Dial Test");
$d = $r->addDial(array('action' => $base_http . "/answered.php", 'timeLimit' => 60, 'hangupOnStar' => 'true'));
$d->addNumber("4871", array('gateways' => "sofia/gateway/pstn", 'gatewayTimeouts' => 30));
$d->addNumber("1749", array('gateways' => "sofia/gateway/pstn", 'gatewayTimeouts' => 30));
}
$r->Respond();
示例6: Response
<?php
require_once "./plivo.php";
# Generates a Conference XML
$r = new Response();
$params = array('enterSound' => "beep:1", 'callbackUrl' => "https://example.com/conf_callback.php", 'callbackMethod' => "GET");
$name = "demo";
$r->addSpeak("You will now be placed into a demo conference. This is brought to you by Plivo. To know more visit us at plivo.com");
$r->addConference($name, $params);
Header('Content-type: text/xml');
echo $r->toXML();
?>
<!--conf_callback.php-->
<?php
require_once "./plivo.php";
# Record API is called in the callback URL to record the conference
$conf_name = $_REQUEST['ConferenceName'];
$event = $_REQUEST['Event'];
print "Conference Name : {$conf_name}";
print "Event : {$event}";
# The recording starts when the user enters the conference room
if ($event == "ConferenceEnter") {
$auth_id = "Your AUTH_ID";
$auth_token = "Your AUTH_TOKEN";
$p = new RestAPI($auth_id, $auth_token);
$params = array('conference_name' => $conf_name);
$resp = $p->record_conference($params);
print "URL : {$resp['response']['url']}";
print "Recording ID : {$resp['response']['recording_id']}";
示例7: Response
echo $r->toXML();
break;
}
?>
<!--phone_tree.php-->
<?php
require_once "plivo.php";
$WRONG_INPUT_MESSAGE = "Sorry, it's a wrong input.";
$r = new Response();
$digit = $_REQUEST['Digits'];
if ($digit == '1') {
$body = "This message is being read out in English";
$params = array('language' => "en-GB");
$r->addSpeak($body, $params);
} else {
if ($digit == '2') {
$body = "Ce message est lu en français";
$params = array('language' => "fr-FR");
$r->addSpeak($body, $params);
} else {
if ($digit == '3') {
$body = "Это сообщение было прочитано в России";
$params = array('language' => "ru-RU");
$r->addSpeak($body, $params);
} else {
$r->addSpeak($WRONG_INPUT_MESSAGE);
}
}
}
示例8: dirname
<?php
// Include the PHP Plivo Rest library
require "./plivohelper.php";
$base_http = "http://" . dirname($_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"]);
/* Render RESTXML */
$r = new Response();
if ($_GET['redirect'] == 'true' || $_POST['redirect'] == 'true') {
$r->addSpeak("Redirect done !");
$r->addHangup();
} else {
$r->addRedirect($base_http . "/answered.php?redirect=true");
}
$r->Respond();
示例9: Response
<?php
require_once "./plivo.php";
# Generate a Record XML and ask the caller to leave a message
$r = new Response();
# The recorded file will be sent to the 'action' URL
$record_params = array('action' => 'https://example.com/record_action.php', 'method' => 'GET', 'maxLength' => '30', 'transcriptionType' => 'auto', 'transcriptionUrl' => 'https://example.com/transcription.php', 'transcriptionMethod' => 'GET');
$r->addSpeak("Leave your message after the tone");
$r->addRecord($record_params);
Header('Content-type: text/xml');
echo $r->toXML();
?>
<!--record_action.php-->
<?php
# Action URL Example
$record_url = $_REQUEST['RecordUrl'];
$record_duration = $_REQUEST['RecordingDuration'];
$record_id = $_REQUEST['RecordingID'];
echo "Record URL : {$record_url}";
echo "Recording Duration : {$record_duration}";
echo "Recording ID : {$record_id}";
?>
<!--transcription.php-->
<?php
# Transcription URL Example
$transcription = $_REQUEST['transcription'];
echo "Transcription is : {$transcription} ";
示例10: Response
<?php
require_once 'plivo-voicemail/plivo.php';
$r = new Response();
/*Input digits can be processed on the action url*/
$g = $r->addGetDigits(array('action' => 'http://server.com/receive_input.php', 'method' => 'GET'));
$g->addSpeak('Press 1 for your message');
$r->addSpeak('Input not received');
header('Content-Type: text/xml');
echo $r->toXML();
示例11: array
<?php
require_once 'plivo.php';
$body = 'Hi, Calling from Plivo. Please enter 1 for music and 2 for Speak.';
// $url = 'http://examples.com/playTrumpet.mp3';
$attributes = array('loop' => 2);
$getdigitattributes = array('action' => 'http://' . $_SERVER["SERVER_NAME"] . '/gather');
// This is the url where 'Digits' parameter would be sent after user's digit press event
$r = new Response();
$g = $r->addGetDigits($getdigitattributes);
$g->addSpeak($body, $attributes);
$r->addSpeak("Input not recieved", array('language' => 'en-US', 'voice' => 'WOMAN'));
echo $r->toXML();
示例12: Number
$g->append(new Number("4155551212"));
$r->append($g);
$r->append(new Play("http://www.mp3.com"));
$r->Respond();
/* outputs:
<Response>
<Speak loop="10">Hello World</Speak>
<Dial timeLimit="45">
<Number>4155551212</Number>
</Dial>
<Play>http://www.mp3.com</Play>
</Response>
*/
// The same XML can be created above using the convencience methods
$r = new Response();
$r->addSpeak("Hello World", array("loop" => "10"));
$g = $r->addDial(array("timeLimit" => "45"));
$g->addNumber("4155551212");
$r->addPlay("http://www.mp3.com");
$r->addHangup(array("schedule" => "45"));
$r->Respond();
// ========================================================================
// GetDigits, Redirect
$r = new Response();
$g = $r->addgetDigits(array("numDigits" => "1", "timeout" => "25", "playBeep" => "true"));
$g->addPlay("/usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr-hello.wav", array("loop" => "10"));
$r->addWait(array("length" => "5"));
$r->addPlay("/usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr-hello.wav", array("loop" => "10"));
$r->addRecord(array("bothLegs" => "true"));
$r->addredirect();
$r->Respond();
示例13: Response
<?php
require_once 'plivo.php';
$response = new Response();
$response->addSpeak('Record your message at the tone, after you are done, press pound');
$response->addRecord(array('action' => 'http://' . $_SERVER["SERVER_NAME"] . '/plivo-voicemail/confirm-input.php', 'method' => 'GET', 'maxLength' => '60', 'finishOnKey' => '#', 'playBeep' => 'true'));
$response->addSpeak('Recording not received');
$response->addRedirect('http://' . $_SERVER["SERVER_NAME"] . '/plivo-voicemail/get-input.php', array('method' => 'GET'));
header('content-type: text/xml');
echo $response->toXML();
示例14: Response
<?php
require_once 'plivo.php';
$response = new Response();
$input_digits = $_REQUEST['Digits'];
if ($input_digits == '1') {
$response->addPlay($_REQUEST['RecordUrl']);
$response->addRedirect('http://' . $_SERVER["SERVER_NAME"] . '/plivo-voicemail/confirm-input.php', array('method' => 'GET'));
} else {
if ($input_digits == '2') {
$response->addRedirect('http://' . $_SERVER["SERVER_NAME"] . '/plivo-voicemail/get-input.php', array('method' => 'GET'));
} else {
if ($input_digits == '3') {
$response->addSpeak('Your message is saved. Bye.');
// do necessary actions to save the recording and call uuid mapping.
} else {
$response->addSpeak('Invalid input');
$response->addRedirect('http://' . $_SERVER["SERVER_NAME"] . '/plivo-voicemail/get-input.php', array('method' => 'GET'));
}
}
}
header('Content-Type: text/xml');
echo $response->toXML();
示例15: dirname
<?php
// Include the PHP Plivo Rest library
require "./plivohelper.php";
$base_http = "http://" . dirname($_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"]);
/* Render RESTXML */
$r = new Response();
if (isset($_POST['Digits'])) {
$digits = $_POST['Digits'];
if ($digits != "") {
$r->addSpeak("Get Digits. Digits pressed " . $digits);
} else {
$r->addSpeak("Get Digits. No digits pressed");
}
} else {
$d = $r->addGetDigits(array("action" => $base_http . "/answered.php", "timeout" => 10, "retries" => 2, "finishOnKey" => "#", "numDigits" => 2, "playBeep" => "true", "validDigits" => "01234"));
$d->addSpeak("Get Digits. Press 0, 1, 2, 3 or 4");
}
$r->Respond();