如何设置HTTP请求的内容类型?
我试过这个:
$headers['Accept'] = 'application/xml'; $headers['Content-Type'] = 'application/xml'; curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
这就是结果:
HTTP/1.1 200 OK content-encoding: gzip Content-Type: text/html;charset=UTF-8 Date: Thu,22 Mar 2012 14:04:36 GMT
但到目前为止没有运气……
在HTTP响应中获取Content-Type:application / xml需要做什么?
我相信标题必须是一个普通的数组,其元素是完整的键:值标题,而不是关联数组:
$headers = array(); $headers[] = 'Accept: application/xml'; $headers[] = 'Content-Type: application/xml'; curl_setopt($ch,$headers);
这在curl_setopt()
documentation.中指定