HTTP_POST, HTTP_GET

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pain
Forum Newbie
Posts: 8
Joined: Wed Jun 15, 2005 7:42 am
Location: Riga, Latvia

HTTP_POST, HTTP_GET

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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);
Post Reply