Twilio / PHP-如何正确编码和解码URL?

时间:2018-12-11 20:27:05

标签: php encoding twilio decoding twiml

我有一个变量:

$name = urlencode('é');

由Twilio调用:

array("url" => "example.com/test1.php?name=$name")

在test1.php中,我的TwiML如下:

<Response> 
    <Gather numDigits="1" method="GET" action="example.com/test2.php?name=<?php echo urlencode($_GET["name"]);?>>
        <Say>Hello,<?php echo urldecode($name);?></Say>
        <Say>To repeat press 1. To confirm, press 2.</Say>
    </Gather>
</Response>

如果我没有对$_GET["name"]进行编码,则会收到应用程序错误“ HTTP检索失败”。我不确定为什么,因为它不应该已经编码了吗?为什么在消息中显示已解码的é,从而导致错误?

我遇到的另一个问题是echo $_GET["name"];echo urldecode($_GET["name"]);都在test2.php中打印é而不是é

最后,要处理此重复,我在test2.php中回到test1.php的重定向链接是否应该包含针对$_GET["name"]的urlencoding?

<Redirect>
    example.com/test1.php?name=<?php echo urlencode($_GET["name"]);?
</Redirect>

如果我知道如何解决我的前两个问题,我可能可以解决这个问题。

0 个答案:

没有答案
相关问题