在 Twilio 中,他们有一个关于 php 中“电话调查”的示例。
电话投票有以下文件,make call.php、poll.php 和 process_poll.php。
拨打电话 php - 包含 SID 等并拨打电话。poll php - 在 Gather 标记中包含实际的投票问题。如此处所示:
<?php
require 'Services/Twilio.php';
$response = new Services_Twilio_Twiml();
$gather = $response->gather(array(
'action' => 'php url to hit',
'method' => 'GET',
'numDigits' => '1'
));
$gather->say("Hi question one here");
$gather->say("From 1 to 5 with 5 being the best service. How would you rate?");
header('Content-Type: text/xml');
print $response;
?>
进程 poll php 包含他们选择选项后的下一步。出于篇幅的原因,我不会在后面发布 db 区域。
if (isset($choices[$digit])) {
mysql_query("INSERT INTO `results` (`" . $choices[$digit] . "`) VALUES ('1')");
$say = 'Ok got it. Next question.';
} else {
$say = "Sorry, I don't have that option. Next question.";
}
// @end snippet
// @start snippet
$response = new Services_Twilio_Twiml();
$response->say($say);
$response->hangup();
header('Content-Type: text/xml');
print $response;
我的问题是我将如何添加其他问题。当前发生的是用户听到第一个问题。从电话垫中选择选项。在对他们的回答进行消息响应后,连接结束。我想再添加大约 3 个问题,然后再回答。如何实现?我会添加一个回复,将他们发送到第二组问题的另一个网址吗?
你能给我一些关于如何实现这一点的指导吗?我是一个php新手。