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.
HTTP GET calls will be made to the web app in format similar to this.
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?
Note that I am not referring to writing a script that listens for network requests on a socket.
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.
Here's some of the code that I've written:
<?php
// Read incoming POST request
if (!empty($_POST)){
$params = join(" ", $_POST);
//print_r($params);
echo "|$params|";
}
// Print params & 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;
?>
Cheers,
Travis