如何让这段代码说 "Please hold" 并播放自定义 mp3?
How do I make this code say "Please hold" and play a custom mp3?
这是主持人加入后开始的会议线路。
它工作得很好,除了我不知道如何让它对所有来电者说 "Please hold, you'll be connected shortly."。
我还想为保留音乐播放自定义 mp3 文件。
<?php
// Get the PHP helper library from twilio.com/docs/php/install
// this line loads the library
require_once '/var/www/one/conference/twilio/Twilio/autoload.php';
use Twilio\Twiml;
// Update with your own phone number in E.164 format
$MODERATOR = '+1347999999';
$response = new Twiml;
// Start with a <Dial> verb
$dial = $response->dial();
// If the caller is our MODERATOR, then start the conference when they
// join and end the conference when they leave
if ($_REQUEST['From'] == $MODERATOR) {
$dial->conference('My conference', array(
'startConferenceOnEnter' => True,
'endConferenceOnExit' => True,
'beep' => True,
'record' => True
));
} else {
// Otherwise have the caller join as a regular participant
$dial->conference('My conference', array(
'startConferenceOnEnter' => False
));
}
print $response;
?>
这里是 Twilio 开发人员布道者。
为了在通话开始时收到消息,您需要使用 TwiML <Say>
verb before you use the <Dial>
。
要在会议开始前播放自定义音乐,您需要使用 waitUrl
attribute on the <Conference>
tag. The waitUrl
is a URL that points at either an MP3 or Wav file or something that returns TwiML which could include multiple <Say>
or <Play>
动词。
这是您的代码更新,其中包括开始时的消息和音乐的 waitUrl
(值得注意的是,主持人在开始会议时不需要 waitUrl
):
// Get the PHP helper library from twilio.com/docs/php/install
// this line loads the library
require_once '/var/www/one/conference/twilio/Twilio/autoload.php';
use Twilio\Twiml;
// Update with your own phone number in E.164 format
$MODERATOR = '+1347999999';
$response = new Twiml;
// Start with a welcome message
$response->say("Please hold, you'll be connected shortly.");
// Then add the <Dial> verb
$dial = $response->dial();
// If the caller is our MODERATOR, then start the conference when they
// join and end the conference when they leave
if ($_REQUEST['From'] == $MODERATOR) {
$dial->conference('My conference', array(
'startConferenceOnEnter' => True,
'endConferenceOnExit' => True,
'beep' => True,
'record' => True
));
} else {
// Otherwise have the caller join as a regular participant
$dial->conference('My conference', array(
'startConferenceOnEnter' => False,
'waitUrl' => 'http://twimlets.com/holdmusic?Bucket=com.twilio.music.classical'
));
}
print $response;
如果这有帮助,请告诉我。
这是主持人加入后开始的会议线路。
它工作得很好,除了我不知道如何让它对所有来电者说 "Please hold, you'll be connected shortly."。
我还想为保留音乐播放自定义 mp3 文件。
<?php
// Get the PHP helper library from twilio.com/docs/php/install
// this line loads the library
require_once '/var/www/one/conference/twilio/Twilio/autoload.php';
use Twilio\Twiml;
// Update with your own phone number in E.164 format
$MODERATOR = '+1347999999';
$response = new Twiml;
// Start with a <Dial> verb
$dial = $response->dial();
// If the caller is our MODERATOR, then start the conference when they
// join and end the conference when they leave
if ($_REQUEST['From'] == $MODERATOR) {
$dial->conference('My conference', array(
'startConferenceOnEnter' => True,
'endConferenceOnExit' => True,
'beep' => True,
'record' => True
));
} else {
// Otherwise have the caller join as a regular participant
$dial->conference('My conference', array(
'startConferenceOnEnter' => False
));
}
print $response;
?>
这里是 Twilio 开发人员布道者。
为了在通话开始时收到消息,您需要使用 TwiML <Say>
verb before you use the <Dial>
。
要在会议开始前播放自定义音乐,您需要使用 waitUrl
attribute on the <Conference>
tag. The waitUrl
is a URL that points at either an MP3 or Wav file or something that returns TwiML which could include multiple <Say>
or <Play>
动词。
这是您的代码更新,其中包括开始时的消息和音乐的 waitUrl
(值得注意的是,主持人在开始会议时不需要 waitUrl
):
// Get the PHP helper library from twilio.com/docs/php/install
// this line loads the library
require_once '/var/www/one/conference/twilio/Twilio/autoload.php';
use Twilio\Twiml;
// Update with your own phone number in E.164 format
$MODERATOR = '+1347999999';
$response = new Twiml;
// Start with a welcome message
$response->say("Please hold, you'll be connected shortly.");
// Then add the <Dial> verb
$dial = $response->dial();
// If the caller is our MODERATOR, then start the conference when they
// join and end the conference when they leave
if ($_REQUEST['From'] == $MODERATOR) {
$dial->conference('My conference', array(
'startConferenceOnEnter' => True,
'endConferenceOnExit' => True,
'beep' => True,
'record' => True
));
} else {
// Otherwise have the caller join as a regular participant
$dial->conference('My conference', array(
'startConferenceOnEnter' => False,
'waitUrl' => 'http://twimlets.com/holdmusic?Bucket=com.twilio.music.classical'
));
}
print $response;
如果这有帮助,请告诉我。