我如何使这段代码说出"请按住"并播放自定义MP3?

时间:2017-02-21 03:57:14

标签: php twilio twilio-php

这是一个会议主题,在主持人加入时开始。

它完美无缺,但我无法弄清楚如何让它说出来#34;请等一下,你很快就会联系起来。"给所有来电者。

我还想为保持音乐播放自定义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;

?>

1 个答案:

答案 0 :(得分:0)

Twilio开发者传道者在这里。

要在通话开始时收到消息,您需要在使用TwiML <Say> verb之前使用<Dial>

要在会议开始前播放自定义音乐,您需要使用waitUrl attribute标记上的<Conference>waitUrl是一个指向MP3或Wav文件的网址,或者返回可能包含多个<Say><Play>动词的TwiML的网址。

以下是您的代码更新,其中包含开头的消息和音乐的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;

让我知道这是否有帮助。