send xml over post


Hits: 1849  

<?php

/*

$url = Web Service Url or Server Url where xml have to post

$xml = XML  schema to post on server

*/

function sendXmlOverPost($url, $xml)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

// For xml, change the content-type.
curl_setopt ($ch, CURLOPT_HTTPHEADER, Array(“Content-Type: text/xml”));

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // ask for results to be returned
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

// Send to remote and return data to caller.
$result = curl_exec($ch);
curl_close($ch);
return $result;

}

?>

Published by

Sandeep Verma

I’m an Entrepreneur. I’m proud to work as Blogger, LAMP Programmer, Linux Admin, Web Consultant, Cloud Manager, Apps Developer, Searcher. Concentrate > Observe > Imagine > Launch

12 thoughts on “send xml over post”

  1. Hello! Quick question that’s totally off topic.
    Do you know how to make your site mobile friendly? My
    blog looks weird when browsing from my iphone4.
    I’m trying to find a theme or plugin that might be able to resolve
    this problem. If you have any suggestions, please share. Appreciate it!

  2. Does your website have a contact page? I’m having a tough time locating it but, I’d
    like to shoot you an email. I’ve got some suggestions for your blog
    you might be interested in hearing. Either way, great site and I look forward
    to seeing it develop over time.

Leave a Reply

Your email address will not be published.

*