I'm trying to post an xml string to an external url using cURL. I'm getting a 400 Bad Request error. Can someone let me know if there's something wrong with this cURL request or if I'm missing something? Note that I was getting a connection failed error until I added the CURLOPT_PROXY line below. Now I'm getting the 400 error. I've also tried adding a curlOPT_HTTPHEADER line with $header but no luck. Any help would be appreciated!
$header = "POST HTTP/1.0 \r\n";
$header .= "Content-type: text/xml \r\n";
$header .= "Content-length: ".strlen($post_string)." \r\n";
$header .= "Content-transfer-encoding: text \r\n";
$header .= "Connection: close \r\n\r\n";
$header .= $post_string;
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_PROXY,"localhost:80");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
$data = curl_exec($ch);
print $data;
if(curl_errno($ch))
print curl_error($ch);
else
curl_close($ch);