You might need to uri_escape() your username and password using URI::Escape before inserting them into your QUERY_STRING. However, the resulting characters might cause issues for your shell. I'm not sure what to do about that second part.
---
It's all fine and dandy until someone has to look at the code.