send xml over post

On October 25, 2009, in Fedora, PHP, Tips, Web Services, by phpsolutions

<?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;

}

?>

4 Responses to send xml over post

  1. Anonymous says:

    You completed several good points there. I did so specific searches within the issue and found virtually all people should go together with together with your blog.

  2. Anonymous says:

    Each time I visit this website there’s a new challenge and improved that i can learn from. Haha I’ve been in your source code multiple times to master how you’re using things to put them on my site. Thanks! I can coach you on about methods to generate income.

  3. Anonymous says:

    Hey! Wanted to go out of a comment. I seriously liked this article. Continue the awesome effort.

  4. Kamberley says:

    Clear, infromative, simple. Could I send you some e-hugs?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.