$userXML = <<
 $name
 $email
 $contact
USERIDATA;
$opts = array(
'http' => array(
    'method' => "POST",
    'header' => "Content-Type: application/xml\r\nAccept: application/xml",
    'timeout' => 30,
    'content' => $userXML,
)
);
$url = 'http://abc.com/getuserdata';
$ctx = stream_context_create($opts);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
 $fp = @fopen($url, 'rb', false, $ctx);
 if (!$fp) {
      throw new Exception("Problem with $url");
 }
}
$response = @stream_get_contents($fp);
$response_array = array();
if ($response == false) {
 throw new Exception("Problem reading data from $url");
} else {
 $response_array = xml_to_array($response);
}
 
 
Comments
Post a Comment