Tuesday, December 29, 2009

Post Xml data without form in PHP and receive

How to post Xml data without form in PHP and receive
=====================================================
If it is not working in localhost/localsystem, try to run it in from live server.


here is the first file which will send xml data

vp-post4.php
-------------
< ? php
#get the xml data from xml file which you want to post
$xml = file_get_contents("temp1.xml");
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml",
'content' => $xml
)));
// put here host name with page name.
// if it is not working in local try to run it in live server.
$file = file_get_contents("http://localhost:90/post/vp-postget4.php", false, $context);
echo $file;
?>


here is the second file which will receive xml data

vp-postget4.php
-------------------

< ? php
$xml = file_get_contents("php://input");
// perform here your operation for received xml data
/////// .....
/////// .....
echo "received data is : ".$xml;
?>

No comments:

Post a Comment