Hello everyone,
I am using the following code to do a post to localhost:
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost/response.php');
//response.php just spits out json_encode($_POST)
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/html"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, Array('data' => $xml));
$curl_result = curl_exec($ch);
if(curl_errno($ch)) {
echo 'Curl error: '.curl_error($ch);
}
curl_close($ch);
echo $curl_result;
//Outputs []
As stated in the comment, nothing gets posted to the server. What am i doing wrong?:confused:
BTW: If i change Array('data'=>$xml) to simply $xml (which is a string constructed previously) it stops working altogether (just as if a syntax error occurred).
Thanks !