如何使用 Twilio\Twiml php 在 <Gather> 中嵌套 Twilio Twiml <Play>

How does one nest Twilio Twiml <Play> inside <Gather> using Twilio\Twiml php

如何将 Play 嵌套在 Gather 中? 我有以下 Twiml xml:

 $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>

使用这个:

$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;