Page 1 of 1

HTTP_POST, HTTP_GET

Posted: Tue Jul 12, 2005 6:48 am
by Pain
maybe somebody can give me an answer or what would be even better a script... A server sends to my server a "message" and I have to process this message and send an answer to the server. Well the problem is that I don't know how to get this message and how to send the answer... Can anyone help me?

p.s. hope you understood the problem... my english isn't as good as it was a few years ago.

Posted: Tue Jul 12, 2005 6:56 am
by timvw
These days most people use XML to package their messages...


So you write a messagehandler.php (Server B should post messages to this script)

Code: Select all

// get the posted XML
$data = file_get_contents('php://input');

// now do stuff with the XML
file_put_contents($data, 'somelog.txt');

// tell the server the answer
echo "<xml>OK</ok>";
Offcourse you also send independant messages to Server B

Code: Select all

require_once('http://timvw.madoka.be/programming/php/client.txt');
$data = file_get_contents('sample.txt');
$result = postXML($data, 'serverb.example.com', 80, '/service.php');
print_r($result);