Hi, I'm sending a POST and trying to receive XML back. What I'm getting back doesn't seem to be formatted properly (it doesn't appear color coded) and so I'm not having any luck parsing it. any help will be much appreciated, Thanks! here's the code and what I get back from it:
function do_post_request($url, $data, $optional_headers = null)
{
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
return $response;
}
//$opt_headers = "Content-Type: text/xml; charset=utf-8";
$opt_headers = '';
$paramString = "xmldata=".$myXMLString."&version=".$myMethodVersion."&username=test_web&password=";
$xmlResult = do_post_request($myURL,$paramString,$opt_headers);
echo $xmlResult;
/*
//load the xml string using simplexml function
$xml = simplexml_load_string($xmlResult);
echo $xml->Return[0]->ReturnValue;
*/
results in the following xml-like response, but with no headers or color formatting:
<T2WsReturn><Return><ReturnField>PERMISSION_UID</ReturnField><ReturnValue>262845</ReturnValue></Return><Return><ReturnField>PERMISSION_NUMBER</ReturnField><ReturnValue>E440900869</ReturnValue></Return><Return><ReturnField>PERMISSION_PRICE</ReturnField><ReturnValue>48</ReturnValue></Return><Return><ReturnField>PERMISSSION_TAX_1</ReturnField><ReturnValue>0</ReturnValue></Return><Return><ReturnField>PERMISSSION_TAX_2</ReturnField><ReturnValue>0</ReturnValue></Return><Return><ReturnField>PERMISSSION_TAX_3</ReturnField><ReturnValue>0</ReturnValue></Return><Return><ReturnField>PERMISSION_EFFECTIVE_DATE</ReturnField><ReturnValue>08/01/2007</ReturnValue></Return><Return><ReturnField>PERMISSION_EXPIRATION_DATE</ReturnField><ReturnValue>07/31/2008</ReturnValue></Return></T2WsReturn>