-1

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

VAD
  • 13
  • 3

1 Answers1

0
header("Content-type: text/xml");
$dom = new DOMDocument('1.0', 'utf-8');
$element = $dom->createElement('xml', 'Accepted');
$dom->appendChild($element);
echo $dom->saveXML();
themadmax
  • 2,344
  • 1
  • 31
  • 36
  • can i echo it without header.I have already Header in that page – VAD Feb 16 '18 at 15:12
  • i am still having the issue as i tried to echo without header.Please help – VAD Feb 16 '18 at 18:47
  • Do you have xml header? What is your error, what is you API? We cannot help you if you did not share all information. – themadmax Feb 19 '18 at 08:12
  • my application has runs on concrete 5 framework.So it has default header and footer from concrete 5.How to echo just this one on that page. – VAD Feb 20 '18 at 19:38