EDITED QUESTION: I want to simulate two different applications. On the first (script X) a form can be submitted and gets handled by itself. He also is POSTing data to a second application (script Y) via REST.
Currently script Y is nothing more then:
<?php
if(isset($_POST)) {
deliver_response(200, "success", $_POST);
}
function deliver_response($status, $status_message, $data) {
header("HTTP/1.1 $status $status_message");
$response['status'] = $status;
$response['status_message'] = $status_message;
$response['data'] = $data;
$json_response = json_encode($response);
echo $json_response;
}
?>
So, when I submit script X, it is POSTing some data to script Y via REST, and above shows how script Y handles the POST request from script X. The echo is being displayed on the screen of script X, but I want to have a second screen with script Y where this echo is being displayed automatically at the moment it receives the POST request from script X.
I hope I made my point clear. Is this somehow possible that script Y just receives the POST request (maybe still sending 200 succes back), but also displays the data it received on it's own screen? If yes, could you give me a hint?
And no, I don't want for script Y to check every few seconds with a GET request if there was submitted some new data at script X.
Thanks in advance!
To refresh the page you could use ajax. http://www.w3schools.com/ajax/default.asp
You could also do a refresh on page Y with PHP
header("Refresh:0");
I ran into same situation some time ago when an external API was to send data on a result URL being hosted at our server. I think you have same issue, just the sender and receiver are both hosted by you.
Script Y must have $recieved_params= file_get_contents(php://input)
This will capture everything posted to this script, then you can process the contents.
Since this page is called by a script, not your browser,it won't just echo stuff, you can redirect your browser when $recieved_params
isn't empty.