enviar y responder con curl

i want receive xml file via curl and respond back. website 'A' sends xml info to webiste 'B', website 'B' need to respond back to 'A'

i know how to do it through post array but can not do it with xml

website 'A' sends this

$xml_data ='<test_data>
      <one>
      <demo>123</demo>
      <demo2>456</demo2> 
      <Password>mypassword</Password>
      </one>
      </test_data>';


   $url = "http://www.domain.com/path/";

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
    curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);
    curl_close($ch);

Website 'B' need to get this and check the data and in database then respond back with a message lets say

$xml_data ='<test_data>
      <one>
      <checked>success</checked>
      <demo>123</demo>
      <demo2>456</demo2> 
      <Password>mypassword</Password>
      </one>
      </test_data>';

preguntado el 08 de noviembre de 11 a las 12:11

1 Respuestas

Prueba esto:

<?php
  $xml_data ='<test_data>
      <one>
      <checked>success</checked>
      <demo>123</demo>
      <demo2>456</demo2> 
      <Password>mypassword</Password>
      </one>
      </test_data>';

  header('Content-type: text/xml');

  echo $xml_data;
?>

respondido 08 nov., 11:16

how do i check the data from website 'A' before responding? - tiempo de espera

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.