0

如您所见,我正在尝试让呼叫者 ID 在呼叫者 ID 的 xml 中显示 To。我怎样才能做到这一点?我究竟做错了什么?我似乎无法把所有事情都做好。我需要一些帮助我不太擅长编码,我在互联网上查找了如何获取大部分内容,但我无法让我的代码正常工作。提前致谢!

<?xml version='1.0' encoding='UTF-8'?> <TwilioResponse><Call><To>+12017447179</To><ToFormatted>(201) 744-7179</ToFormatted><From>+16463621515</From><FromFormatted>(646) 362-1515</FromFormatted><PhoneNumberSid/><Status>queued</Status><StartTime/><EndTime/><Duration/><Price/><PriceUnit>USD</PriceUnit><Direction>outbound-api</Direction><AnsweredBy/><ApiVersion>2010-04-01</ApiVersion><Annotation/><ForwardedFrom/><GroupSid/><CallerName/></Call></TwilioResponse>


http://gordonbusiness.com/vb_menu.xml


<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather action="="/forward_call.php" numDigits="1">
<Play loop="2">https://gordonbusiness.com/studentloan.mp3</Play>
</Gather>
<Say>Sorry, I didn't get your response.</Say>
<Redirect>vb_menu.xml</Redirect>
</Response>

http://gordonbusiness.com/forward_call.php -

Response sent to 2nd URL:
1   $user_pushed = (int) $_REQUEST['Digits'];


<?php
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<Response>';
# @start snippet$
user_pushed = (int) $_REQUEST['Digits'];
# @end snippet
$string_data = "<TwilioResponse>";
$xml = simplexml_load_string($string_data);
$phonenumber == (string) $xml->To;
if ($user_pushed == 1)
{
echo '<Dial callerId=$phonenumber>
<Number>+18552426127</Number>
</Dial>';
}
else if ($user_pushed == 9)
{
echo '<Hangup />';
}
4

1 回答 1

0

Twilio 开发人员布道者在这里。

我认为您拥有大部分权利,缺少的一点是将拨打的号码作为来电显示。

您似乎正在从您创建的一些匿名 XML 结构中构建“收件人”编号。您可以从请求参数中获取 To 编号。就像你得到了Digits参数一样。

所以,而不是

$string_data = "<TwilioResponse>";
$xml = simplexml_load_string($string_data);
$phonenumber == (string) $xml->To;

你可以$phonenumber像这样设置:

$phonenumber = $_REQUEST["To"];

让我知道这是否有帮助。

于 2015-07-15T03:32:44.840 回答