2011-09-27 66 views
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; 
} 

回答

3

您已將RETURNTRANSFER標誌設置在錯誤的變量上。更改$curl$ch

0

你要排隊一個錯字: 「curl_setopt($捲曲,CURLOPT_RETURNTRANSFER,真正的);」

它應該閱讀:

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);