Is there a reason why a PHP cURL enblaed server will refuse to display xml responses? I have been working on a script to post numbers to a dialling service. I felt using cURL would be the best thing to do.
On 3 different servers, each running different versions of PHP, I am able to get responses with no problems. But on the particular server, no matter how many times I try, I just get a blank response.
This the script in question:
<?php
if ($_POST['request_callback'])
{
$customer_name = cleaninput($_REQUEST['customer_name'],"text");
$debtor_id = cleaninput($_REQUEST['debtor_id'],"number");
$telephone_number = cleaninput($_REQUEST['customer_number'],"number");
$xml_request = '<?xml version="1.0" encoding="utf-8"?>';
$xml_request .= '<CallRequest>';
$xml_request .= '<ProjectName>Noble Test</ProjectName>';
$xml_request .= '<ContactNumberToDial>'.$telephone_number.'</ContactNumberToDial>';
if (isset($_POST['callme_now'])) {
$xml_request .= '<DateTimeToDial></DateTimeToDial>';
} else {
$xml_request .= '<DateTimeToDial>' . date('Y-m-d ' . $_POST['hour_select'] . ':' . $_POST['minute_select'] . ':s') . '</DateTimeToDial>';
}
$xml_request .= '<ListSource>WebLead</ListSource>';
$xml_request .= '<AgentName></AgentName>';
$xml_request .= '<AddToList>False</AddToList>';
$xml_request .= '<SpecificAgent>False</SpecificAgent>';
$xml_request .= '<DBField>';
$xml_request .= '<FieldName>Name</FieldName>';
$xml_request .= '<FieldValue>NobleTesting</FieldValue>';
$xml_request .= '</DBField>';
$xml_request .= '</CallRequest>';
$loginUsername = "username";
$loginPassword = "password";
//$user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
// Send using CURL
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, "http://194.217.1.2/ClickToCall/CallRequest.asmx/Call"); // URL to post
//curl_setopt( $ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt( $ch, CURLOPT_USERPWD, "$loginUsername:$loginPassword"); //login
curl_setopt( $ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
// curl_setopt( $ch, CURLOPT_HEADER, 1); // make sure we get the header
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); // return into a variable
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); # required for https urls
curl_setopt( $ch, CURLOPT_POSTFIELDS, 'xmlString=' . urlencode($xml_request));
curl_setopt( $ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt( $ch, CURLINFO_HEADER_OUT, 1);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec( $ch ); // runs the post
curl_close($ch);
}
?>
This runs well everywhere else but this particular server where a response is not sent back. I have also used Firebug to check the request and response headers and both turned out to be empty.
Can anyone help out?
Thanks
James