我正在使用Twilio构建一个简单的调用应用程序。我使用Twilio的PHP库提供的Services_Twilio_Twiml类来构建动态Twiml,而不是使用静态twiml。
我让它在简单的事情上工作得非常好,但是,我不能为我的生活弄清楚如何在php库的collect语句中嵌套说/播放动词。
这就是我所拥有的:
$this->gather(array ("action" => "http://pbx.somedomain.com/twilio/inbound/step/mainmenu_ivr")); (when keypad entry occurs it hits the action url)
我需要复制的是这种twiml行为以某种方式使用传入的数组:
<gather action="http://pbx.somedomain.com/twilio/inbound/step/mainmenu_ivr">
<say>Please enter your extension.</say>
</gather>
如何构造我传递给gather函数的数组以将say在statement语句中嵌套?
提前致谢。
答案 0 :(得分:2)
试试这个:
require('/path/to/twilio-php/Services/Twilio.php');
$response = new Services_Twilio_Twiml();
$gather = $response->gather(array('action' => 'http://pbx.example.com'));
$gather->say('Please enter your extension');
print $response;
此页面上列出了更多示例,Creating TwiML with PHP。