Forum Moderators: coopster

Message Too Old, No Replies

daemon process

daemon process and post the XML request

         

anand paranjape

3:20 am on Mar 18, 2005 (gmt 0)

10+ Year Member



Hi ,

I am designing website forms and on submittion i am writing them to xml file. now i am posting XML request to another application server which
record the form data in it. Now what i require is :

1. How to make daemon process in php so that after some interval of time it runs the script/page which post the XML request to the server.

2. After i post the XML request i got the reponse from the server.. how to read that response from the server.

this is code of PHP file :
------------------------------------------------------------------------------------
<?php
// a file contain post data
$file = "abc.xml";
$remote_url = "/xmlengine";
$remote_server = "localhost";
// read post data
$data = file($file);

// built up POST data
$request = "";
for ($i=0;$i<count($data);$i++)
{
$request .= $data[$i];
}

// Build the header
$header = "POST $remote_url HTTP/1.0\r\n";
$header .= "Host: $remote_server\r\n";
$header .= "Content-type: text/xml\r\n";
$header .= "Content-length: " . strlen($request) . "\r\n\r\n";
// Open the connection
$fp = fsockopen($remote_server, 8090);
if ($fp)
{
// Send HTTP request
fputs($fp, $header . $request);
print "HEADER :: <br/>" . $header . $request;
// Get the response
$response="";
while (!feof($fp))
$response .= fgets($fp, 128);
fclose($fp);
print "RESPONSE :: <br />" . $response;
}
else
die ("Cannot connect!");
?>
------------------------------------------------------------------------------------

Please treat it as urgent.

Have a nice day
~Anand

anand paranjape

6:30 pm on Mar 18, 2005 (gmt 0)

10+ Year Member



Hi.. Can anyone helpme on this.

Thanx in advance
~Anand

jatar_k

10:12 pm on Mar 18, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld anand paranjape,

1. use a cron [google.com]

2. well that depends, I would get them to post it to a script that will parse it

anand paranjape

1:08 am on Mar 19, 2005 (gmt 0)

10+ Year Member



Hi Jatar,
I get response in a XML file.. how do I read the file. I get the confirmation of data saved and id of saved data in xml format. can you please give me the sample script that reads the respnse xml. What i want to do is update the flag in DB depending upon the resonse.

Thanx
~Anand

jatar_k

10:22 pm on Mar 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you could look at XML Parser Functions [php.net] or even XML-RPC Functions [php.net]

anand paranjape

12:09 am on Mar 22, 2005 (gmt 0)

10+ Year Member



Hi Jatar,
Can you please give me the sample script. I want response xml in a variable so that i can display it and search the data in it.

Thank you
~Anand