Twilio 处理呼叫
Twilio handling calls
我想实现的是,每当我收到带有某些关键字的短信时,我都会接到一个电话,说我收到了一条短信,然后按 1 与发送短信的人通话。
我已经创建了三个文件,它们在下面
Twilio.php
这会收到 post 短信请求并给我打电话
$name = $_POST['name'];
$phone = $_POST['phone'];
$client = new Services_Twilio($AccountSid, $AuthToken);
try {
// make call
$call = $client->account->calls->create(
$caller,
$number,
array("url" => "http://somewebsite.net/twilio/twiml.php?phone=$phone&name=$name")
);
} catch (Exception $e) {
echo 'Error starting phone call: ' . $e->getMessage();
}
下一个文件 if twiml.php 处理来电问我要不要发言按1发言
twiml.php
$nm = $_GET['name'];
$ph = $_GET['phone'];
$name = "Deepak";
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
<Say>Hello <?php echo $name ?>.</Say>
<Gather numDigits="1" action="http://somewebsite.net/twilio/call.php?phone=<?php echo $ph ?>" method="POST">
<Say>You have a text message, press 1 to speak.</Say>
</Gather>
</Response>
如果我按 1 说话然后拨那个号码,就会调用第三个文件:下面是代码:
Call.php
<?php
if($_REQUEST['Digits'] != '1') {
header("Location: twiml.php");
die;
}
$ph = $_GET['phone'];
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
<Dial>+1 <?php echo $ph ?></Dial>
</Response>
我想要实现的是将这三个文件合并为一个文件,这样我就不需要发出 Post 请求,我可以在一个文件中处理整个调用,或者至少我可以合并 twiml.php 和 call.php
有没有办法结合这些?
我想实现的是,每当我收到带有某些关键字的短信时,我都会接到一个电话,说我收到了一条短信,然后按 1 与发送短信的人通话。
我已经创建了三个文件,它们在下面
Twilio.php
这会收到 post 短信请求并给我打电话
$name = $_POST['name'];
$phone = $_POST['phone'];
$client = new Services_Twilio($AccountSid, $AuthToken);
try {
// make call
$call = $client->account->calls->create(
$caller,
$number,
array("url" => "http://somewebsite.net/twilio/twiml.php?phone=$phone&name=$name")
);
} catch (Exception $e) {
echo 'Error starting phone call: ' . $e->getMessage();
}
下一个文件 if twiml.php 处理来电问我要不要发言按1发言
twiml.php
$nm = $_GET['name'];
$ph = $_GET['phone'];
$name = "Deepak";
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
<Say>Hello <?php echo $name ?>.</Say>
<Gather numDigits="1" action="http://somewebsite.net/twilio/call.php?phone=<?php echo $ph ?>" method="POST">
<Say>You have a text message, press 1 to speak.</Say>
</Gather>
</Response>
如果我按 1 说话然后拨那个号码,就会调用第三个文件:下面是代码:
Call.php
<?php
if($_REQUEST['Digits'] != '1') {
header("Location: twiml.php");
die;
}
$ph = $_GET['phone'];
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
<Dial>+1 <?php echo $ph ?></Dial>
</Response>
我想要实现的是将这三个文件合并为一个文件,这样我就不需要发出 Post 请求,我可以在一个文件中处理整个调用,或者至少我可以合并 twiml.php 和 call.php
有没有办法结合这些?