duanhe6799 2018-12-11 20:27
浏览 39

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

I have a variable:

$name = urlencode('é');

which is being called by Twilio:

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

In test1.php, my TwiML looks like:

<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>

If I don't encode the $_GET["name"] in action, I get an application error "HTTP retrieval failure". I'm not sure why because shouldn't it already be encoded? Why is it showing the decoded é in the message, resulting in the error?

Another problem I'm having is echo $_GET["name"]; and echo urldecode($_GET["name"]); both print é instead of é in test2.php.

Lastly, to handle the repeat, should my redirect link in test2.php back to test1.php contain urlencoding for $_GET["name"]?

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

I can probably figure this one out if I know how to fix my first 2 problems.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 树莓派与pix飞控通信
    • ¥15 自动转发微信群信息到另外一个微信群
    • ¥15 outlook无法配置成功
    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题