简体   繁体   中英

Creating php xml listener and listening.Having trouble in responding back an XML

I am using a third party API in the system which post xml data to my URL which I get and process the xml. They are saying server has to reply back as Accepted. I am having trouble in this part.

Example:

if ( $_SERVER['REQUEST_METHOD'] === 'POST' )
{
    //Read the xmlinput and write to the file
    $xml = file_get_contents('php://input');
   //...processing the xml and storing to my SQL...

   //How to reply back as '<xml>Accepted</xml>'

}

Please need help.I am able to process xml file and get the data but having sending them back xml reply.

Note:API post results to URL. My server should respond with "Accepted" if successful

header("Content-type: text/xml");
$dom = new DOMDocument('1.0', 'utf-8');
$element = $dom->createElement('xml', 'Accepted');
$dom->appendChild($element);
echo $dom->saveXML();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM