2016-08-01 30 views
1

目標:我希望在創建通話時,應該播放音樂而不是響鈴,並且沒有人可以撥打電話。在播放音樂後應該說出來。 ,它應該重定向到反饋頁面twilio play保持音樂並重定向撥打

現在過:創建呼叫,當我們選擇當撥打電話

呼叫,並反饋頁面運行的MP3播放所以我想一個解決方案來處理這個

<?php 
    if (($nowtime >= $start_time) && ($nowtime <= $end_time)){ 
     $the_mnum = $con ->load_field($the_id, 'the_mnum'); 
     //$m= $the_mnum; 
     //echo $the_mnum; 
?>  <Say voice="woman"> 
     We are directing your call to the therapist. 
     </Say> 


<?php 
     $check_therapist = true; 
     $_SESSION["the_mnum"] = $the_mnum; 
     break; 
    } 
    } 

    if ($check_therapist){ 

    $version = ''; 
    $sid = ''; 
    $token = ''; 
    $client = new Services_Twilio($sid, $token, $version); 
    $call = $client->account->calls->create("+1", $the_mnum, "wekaw1.mp3", array()); 
echo $call->sid; 

    ?> 
<Redirect>feedback.php</Redirect> 
    <?php } else {?> 
    <Say voice="woman"> 
     No listener is available right now. 
     We will give you a call back shortly when we have available listener. 
    </Say> 
<?php } ?> 
</Response> 

回答

1

爲了前2個玩數字遊戲保持音樂,而不是環的連接,你需要使用<Enqueue><Queue>合併,並開始通過我們的REST API的調用。

以下是implementation in PHP的示例。

您需要將以下文件分配到您的電話號碼。此代碼將撥打<enqueue>並啓動呼叫轉移至您的號碼。這也會向第二個需要創建的文件(modify_leg.php)發起一個請求。

在一些文件first.php:

$name = $_POST['CallSid']; 

echo '<Response><Enqueue>'.$name.'</Enqueue></Response>'; 

// Make sure to include php-helper library 
require('../Services/Twilio.php'); // Loads the library 
$account_sid = 'ACxxxxxxxxxxxxxxxxx'; 
$auth_token = 'aaxxxxxxxxxxx'; 
$from_number = '+1xxxxxx'; 
$to_number = '+1xxxxxxxx'; 
$client = new Services_Twilio($account_sid, $auth_token); 
$message = $client->account->calls->create($from_number, $to_number, 'http://Your-FQDN/modify_leg.php?callSid='.$name); 

現在(modify_leg.php)你會通過$_GET[callSid]所以一旦你接聽電話它實際上將兩個呼叫連接,來電者聽音樂,直到你真正拿起呼叫。

<?php 

$who = $_GET['callSid']; 

?> 
<Response> 
<Dial><Queue><?php echo $who ?></Queue></Dial> 
</Response>