7.1

Table Of Contents
Sample POST receive script
The following script is a sample on how to receive POST data in PHP. The code receives the XML data sent by the XML to File
connector and writes this information to disk using the ID of the order. The sample file can be found at the following location:
C:\Program Files\PrintShop Mail Suite 7\PrintShop Mail Web\Website\modules\mis\xml_to_file_mis\sample
<?php
/**
* Sample POST receive page
*
* This demo script creates a xml file based on the OrderID of the received XML.
* The file is saved directly under the "C" directory
*
* To use this script, the following must be applied
* The module "XML to File" must be activated on "Settings"
* Either "Post" or "Move to folder and Post" must be selected as "PushMethod"
* "http://localhost/modules/mis/xml_to_file_mis/sample/receive.php" must be entered in
"URL"
* Finally, as you change the status of the order, then "OrderID.xml"
* will be created in "C" directory
*
*/
$aJobXML = simplexml_load_string($_POST['PSW_XML']);
if ($aJobXML === false) {
echo "Cannot parse XML";
exit();
}
$aOrderID = $aJobXML->xpath('//fnOrderID');
if ($aOrderID === false) {
echo "Cannot extract fnOrderID from XML";
exit();
}
$cPath = "C:/" . intval($aOrderID[0]) . ".xml";
$handle = @fopen($cPath, 'w');
if ($handle === false) {
echo "Cannot open or create xml file ($cPath)";
exit();
}
$nWritten = @fwrite($handle, $_POST['PSW_XML']);
if ($nWritten === FALSE) {
echo "Cannot write to xml file ($cPath)";
}
fclose($handle);
chmod($cPath, 0777);
?>
Sample POST receive script
©2010 Objectif Lune Inc - 185 -