如何让此代码表示“请按住”并播放自定义的mp3?

问题描述:

这是会议线,开始于主持人加入时。如何让此代码表示“请按住”并播放自定义的mp3?

它完美的作品,除非我不知道如何让它说:“请握住,你很快就会连接。”给所有来电者。

我也想播放保存音乐的自定义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,然后再使用<Dial>

要在会议开始前播放自定义音乐,您需要在<Conference>标记上使用waitUrl attributewaitUrl是指向MP3或Wav文件或返回TwiML的内容的URL,其中可能包含多个<Say><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; 

让我知道如果这有帮助的话。

+0

谢谢@philnash我把放在拨号错误的地方,现在这个说法可行,但我的自定义mp3 waitUrl仍然没有。我把它放在和上面一样的地方,像'waitUrl'=>'https://www.website.com/Vivaldi-Andante.mp3',但它不起作用。 – user2001109

+0

只是一个想法,也许我的自定义waitUrl没有工作,因为我在我的主持人来电显示 - 我会稍后尝试一个不同的数字。再次感谢@philnash - 发表意见是一个巨大的帮助! – user2001109

+0

好的,我从我的非主持人手机进行了测试,我得到了期望的Vivaldi!答案完美。 – user2001109