[SOLVED] XML - Grabbing pure XML thru POST (not using xmlrpc
Posted: Mon Oct 18, 2004 6:28 am
Hello all, lets see how you deal with this.
I have a php page that sits waiting for something to be sent to it (using POST)
Then basically echos out the POST as shown below:
Now, when I use curl to send it some post data using the code below it echos out the array fine.
However, when i try and force this page into sending the request as pure XML as opposed to the form encoded 1 shown above by adding the line
curl_setopt ($ch,CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
into the curl handler and changing
curl_setopt($ch,CURLOPT_POSTFIELDS,"xml=$xmlvars"); to
curl_setopt($ch,CURLOPT_POSTFIELDS,$xmlvars);
(ie not setting the posts variable name to xml so that it can be picked up on the next page as $_POST
I have a php page that sits waiting for something to be sent to it (using POST)
Then basically echos out the POST as shown below:
Code: Select all
<?php
print_r($_POST);
?>Code: Select all
<?php
$xmlvars='
<?xml version="1.0" ?>
<bht_fgsr>
<depalc>GLA</depalc>
<destalc>ALC</destalc>
<outdate>23/10/04</outdate>
<retdate>30/10/04</retdate>
<adt>1</adt>
<chd>0</chd>
<inf>0</inf>
</bht_fgsr>';
$ch=curl_init("http://127.0.0.1/ws/catch.php");
curl_setopt($ch, CURL_HTTP_VERSION_1_1, true);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_TIMEOUT,60);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,"xml=$xmlvars");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$result=curl_exec($ch);
echo $result;
?>curl_setopt ($ch,CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
into the curl handler and changing
curl_setopt($ch,CURLOPT_POSTFIELDS,"xml=$xmlvars"); to
curl_setopt($ch,CURLOPT_POSTFIELDS,$xmlvars);
(ie not setting the posts variable name to xml so that it can be picked up on the next page as $_POST
Code: Select all
) it just brings back 'array' as the response.
Now, apparently in asp this is dead easy to pick up this post even although it doesnt hold a variable name. Although the guy I originally asked had no idea how it could be done in php. Can anyone help! PLEASE!!! lolz
PS I really dont want to have to use XMLRPC or NuSoap or any of the other stuff thats already out there. It cant be that hard to grab this POST, surely :?
luv n kisses
Me.