【发布时间】:2011-09-27 09:10:42
【问题描述】:
我正在使用 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;
}
【问题讨论】: