I have a script I have been using on my old host that I am moving to a new host. It uses curl to post data to a remote server, receives, and displays the results.
$XPost = "foo";
$url = "https://erewhon.com/important";
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 4); // times out after 4s
curl_setopt($ch, CURLOPT_POSTFIELDS, $XPost); // add POST fields
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$result = curl_exec($ch); // run the whole process
echo $result; //contains response from server
echo "<p>End contents.<br>";
$filename = 'out.xml';
$somecontent = $result;
This script executes fine on old host but returns no $result on new host. Both 'out.xml' files are writable to my account users at both providers. Is there any issue with PHP running as CGI for curl?
I crawled around looking for environment settings that are different and all I could find is:
- New host has a newer zlib compiled with curl (0.9.7a zlib0.9.6b zlib) vs. 0.9.6b zlibon the host were script executes normally.
- New host runs PHP as CGI, the host where script executes normally runs PHP as a module.
I can see no other possible explanations for the different results. Any suggestions?