PHP echo user name (YouTube)

Okay.

I’m trying to pull the users name from the YouTube chat box when a custom channel command has been given.
The custom command !test triggers the call below.

$(urlfetch http://domain.com/test.php?user=$(touser))

On domain.com/test.php I have (I know not really secure as is, but it’s just a test) the following code.

<?php
echo "Hello " . $_GET['user'];
?>

This is working fine EXCEPT when the username has a & (ampersand) in it.
ie: If the name is me & you it will only echo back me

Anyone here who might know how to fix this?

@Noel

Use $(querystring) to ensure the name given in $(touser) is always properly sent to your API:

$(urlfetch http://domain.com/test.php?user=$(querystring $(touser)))
1 Like

That did the trick. Thank you @RokettoJanpu RokettoJanpu

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.