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;
}