我使用PHP捲曲後使用IP,我fullfilled全部爲使其工作,但仍然得到「錯誤的請求」的錯誤要求某些XML數據到另一臺服務器。 看看下面的代碼。掌握在PHP POSTING XML數據捲曲壞請求
$var2 ="<doc><item>Some content.</item></doc>";
$url = "server IP";
$header = "POST HTTP/1.1 \r\n";
$header .= "Content-type: text/xml \r\n";
$header .= "Content-length: ".strlen($var2)." \r\n";
$header .= "Content-transfer-encoding: text \r\n";
$header .= "Connection: close \r\n\r\n";
$header .= $var2;
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_POSTFIELDS, $var2);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
// Get Response
$data = curl_exec($ch);
if(curl_errno($ch))
print curl_error($ch);
else
curl_close($ch);
echo $data;
需要儘快幫助。
感謝