Here are my code samples:
function xmlPostStore($post_xml, $url, $port) {
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1); // Fail on errors
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_PORT, $port); //Set the port number
curl_setopt($ch, CURLOPT_TIMEOUT, 15); // times out after 15s
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_xml); // add POST fields
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
what i'm sending:
$XML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<SendConfig>
<Request>
<key>passphrase</key>
</Request>
</SendConfig>";
$reply = xmlPostStore($XML, "http://www.urlhere.com/test.php", "80");
test.php is just a simple XML return:
echo "<?xml version='1.0' encoding='utf-8'?>
<response>
<config>
<test>it works</test>
</config>
</response>";
When I test this on one server, it works 100% of the time. I receive a response and there's no issues.
When I test it on our main server, it returns back nothing, most of the time, about 98% of the time it's blank. Without any code changes, it will randomly work and randomly stop. I'm stumped.
$replyvariable? It is storing the returned data!