SMS Custom PHP failing

Hello to all,

I have been struggling with below PHP to be executed via

http://myhost/playsms/handler.php?msg1={CUSTOMPARAM}

handler.php reads variable msg1 and is using jason to pass it to Javascript with later executing a script to a remote server.

When handler.php is executed directly from browser is works as expected with the delay http get -> jason -> JS -> http post to remote server.

Please help on what it might be wrong for the below not to execute via SMS custom

<?php
header("HTTP/1.1 200 OK");
if (isset($_REQUEST['msg1'])) {
    $msg1 = $_REQUEST['msg1'];
    ?>
    <script type="text/javascript" src="https://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="http://signage.me/demo/sendCommand.js"></script>
    <script type="text/javascript">
      $(document).ready(function()
      {
           sendCommand("galaxy.signage.me", "username", "password", "13", "new1", (msg1 = <?php echo (json_encode($msg1)); ?>));  
         });
    </script>
    <?php
}
?>

Hello some help!

Really struggling to get the code to work with {CUSTOMPARAM} value

If I use browser and a numeric values it will show fine please please help