PHP Curl Not Behaving Like Command Line Curl PHP Curl Not Behaving Like Command Line Curl curl curl

PHP Curl Not Behaving Like Command Line Curl


Try to modify the content-type option from:

curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));

to :

curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));


It's worth noting that the cURL PHP has installed doesn't have to be the same version as the one you have installed on you server. Check to see what version you have installed on CLI ($ curl --version) and then check PHP with something like <?php phpinfo();.


The problem was not PHP. I was not paying close attention to the error output from the server. Command line curl was failing at the same place every time due to a database constraint on a transaction id but was actually displaying the expected output causing me to think it was working correctly.

PHP, which was using the current hour, minute, second for the transaction id was getting past the point of failure in the command line and failing at a null value, which was actually a problem with my XML. The problem was the null value is an unhandled exception in the code on the remote server so the response back left me thinking something else had gone wrong.

Thanks for the help and sorry about the wild goose chase.