How to send XML data using PHP and CURL

 

<?php
//paste your XML file here
$xml = '
<?xml version="1.0" encoding="UTF-8"?>
<Parent>
<Child>
<Name>Roshini</Name>
<Age>5</Age>
</Child>
</Parent>';
// give the path of the Third party site
$url = "https://www.example.com/";
$ch = curl_init($url);
//curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
echo $output;
curl_close($ch);
?>

Post a Comment

0 Comments