1
我使用curl做post请求,由于某种原因它打印xml响应,这是我不想发生的事情。我怎样才能摆脱这种行为?为什么curl打印XML响应?
/**
* Send post request
**/
function post_request($sendHttpUrl, $data) {
$ch = curl_init($sendHttpUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}