0

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.

Sam96
  • 1
  • 2
  • It looks like you've got a mismatch between UTF-8 and ISO8859-1. You need to standardize on UTF8. https://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Sammitch Dec 11 '18 at 20:30
  • A proper UTF-8 encoded `é` will be `%C3%A9`, ISO8859-1 encoded will be `%E9`. – Sammitch Dec 11 '18 at 20:35
  • @Sam96 I'm a developer evangelist at Twilio, just wondering if you got this sorted? Sounds like Sammitch's ideas make sense. – philnash Dec 17 '18 at 03:36
  • @philnash yes, I was able to get this sorted. I have another question, however. For outbound voice calls, is it possible to not leave a voicemail if the other end doesn't pick up? – Sam96 Dec 17 '18 at 20:45
  • You might want to look into [answering machine detection](https://www.twilio.com/docs/voice/answering-machine-detection) for that, though the feature is still in beta. – philnash Dec 17 '18 at 22:33

0 Answers0