我希望将以下内容翻译成 PHP CURL。
$.ajax({
url:"MY_URL",
cache: false,
type: "POST",
data: "",
dataType: "xml",
success: function(data) {
alert('Eureka!')
}
});
我特别有兴趣弄清楚如何更改以下内容以将 dataType 设置为 xml。以下代码不起作用:
$ch = curl_init('MY_URL');
curl_setopt($ch, CURLOPT_HEADER, 0); // get the header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch,CURLOPT_HTTPHEADER,array (
"Content-Type: xml; charset=utf-8",
"Expect: 100-continue",
"Accept: xml"
));
谢谢!