2017-05-31 71 views
0

如何嵌套在Gather中播放? 我有以下Twiml XML:如何使用Twilio Twiml嵌套Twilio Twiml <Play><Gather> php

$twiml = new Twiml(); 
    $twiml->gather('gather',array()); 
    $twiml->play('https://api.twilio.com/cowbell.mp3', array("loop" => 5)); 
    $response = Response::make($twiml, 200); 
    $response->header('Content-Type', 'text/xml'); 
    return $response; 

要求的結果:

<?xml version="1.0" encoding="UTF-8"?> 
<Response> 
<Gather input="speech" action="/completed"> 
    <Play loop="5">https://api.twilio.com/cowbell.mp3</Play> 
</Gather> 

回答

1

使用此:

$twiml = new Twilio\Twiml(); 
$gather = $twiml->gather(array('input' => 'speech', 'action' => '/completed')); 
$gather->play('https://api.twilio.com/cowbell.mp3', array("loop" => 5)); 

$response = Response::make($twiml, 200); 
$response->header('Content-Type', 'text/xml'); 
return $response; 
相關問題