title: PHP listener script that can read incoming $_REQUEST or $_POST variables
body: <p>I am trying to write a PHP script that listens for incoming $_REQUEST or $_POST variables that are sent by a web application as part of a 2-way communication. </p>
  
  <p>HTTP GET calls will be made to the web app in format similar to <a href="https://WEBAPPNAME.com/sendmsg?text=BLAH&amp;replyTo=http://TRAVISNG.com/listener.php" rel="nofollow">this</a>.</p>
  
  <p>The WEBAPP will then send a POST response to my listener script (http://TRAVISNG.com/listener.php) and so I was wondering if my php script could parse it without me executing the php script manually?</p>
  
  <p><strong>Note that I am not referring to writing a script that listens for network requests on a socket.</strong></p>
  
  <p>Basically, I want to parse the POST data sent by the web app and write it out to a log file. Therefore, every time I run my listener script it will read the log file and print out all the POST responses sent to my listener script.</p>
  
  <p>Here's some of the code that I've written:</p>
  
  <pre><code>&lt;?php
  
      // Read incoming POST request
      if (!empty($_POST)){
          $params = join(" ", $_POST);
          //print_r($params);
          echo "|$params|";
      }
  
      // Print params &amp; timestamp to file called listenerLog.txt
      $logFile = "http://travisng.com/listenerLog.txt";
  
      $fileHandle = fopen($logFile, 'a') or die("Unable to open the listenerLog.txt.");
      fwrite($fileHandle, $params);
      fclose($fileHandle);
  
      $output = file_get_contents($logFile);
  
      // Print listenerLog.txt
      //echo $output;
  
  ?&gt;
  </code></pre>
  
  <p>Cheers,</p>
  
  <p>Travis</p>