Location: PHPKode > scripts > API > api/my_server.php
<?php
/**
 * Created on 2008/12/03
 * Created by KS Tuhin
 * 
 * This module send information to client module
 */

include_once("server_class.php"); // xml parse and generate new xml for send information to client

$server = $_SERVER[HTTP_HOST];

 
if ($HTTP_RAW_POST_DATA) { 
 	$request_xml = $HTTP_RAW_POST_DATA;
}else {
  $request_xml = implode("\r\n", file('http://YOUR SERVER NAME/api/basic.xml')); // IF NOT POST DATA
}

// Section 2: Create Server
$x = new xml_server();

// Section 3: parse XML
if ($x) {
  $success = $x->parse_xml($request_xml);
}
else {
 $x->errno = "200";
}

// Section 4: generate XML response
$results = $x->generate_xml();
// Section 5: send XML response
//print $results;

$server  = "CLIENT SERVER NAME";
$url = 'http://CLIENT SERVER NAME/api/client.php'; // CLIENT SERVER FILE PATH


$content_length = strlen($results); 
$headers= sprintf("POST %s HTTP/1.0\r\nContent-type: text/xml\r\nHost: %s\r\nContent-length: %d\r\n\r\n",$url,$server,$content_length);
$fp = fsockopen($server, 80, $errno, $errstr, 30); 
if (!$fp) return false; 
fputs($fp, $headers); 
fputs($fp, $results); 
$ret = ""; 
while (!feof($fp)) { 
$ret.= fgets($fp, 1024); 
} 
fclose($fp);
$datas = split("\r\n\r\n", $ret, 2);
$header = $datas[0];
$body   = $datas[1];
/**
 * This header and body send information
**/
/*$body = '<form action="form_action.asp" method="get">
  Email: <input type="text" name="email" size="35" /><br />
  PIN: <input type="text" name="pin" maxlength="4" size="4" /><br />
  <input type="submit" value="Submit" />
</form>';*/

echo $body;
exit; 
?>
Return current item: API