下面代码怎么修改可以获得resonse header 非常感谢public static function getResponseByPostXml($url,$xml_data)
{
$header[] = "Content-type: text/xml";//define content-type as xml
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
$response = curl_exec($ch);
if(curl_errno($ch))
{
print curl_error($ch);
}
file_get_contents($url);
curl_close($ch); return $response;
}

解决方案 »

  1.   

    你的$response包含了response header。
    用print_r($response);打印出返回内容就知道了。
      

  2.   


    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
      <MethodResponse>
      <ErrorCode>0</ErrorCode> 
      </MethodResponse>返回上面这样的数据 没有header 郁闷呀
      

  3.   

    前面要加上
    curl_setopt($ch, CURLOPT_HEADER, true);
    才会在输出中包含header
      

  4.   

    还有个问题
    HTTP/1.1 200 OK
    TOKEN: Ciyvab0tregdVsBtboIpeChe4G6uzC1v5_-SIxmvSLIHtcrLGXASvkJBsWFG_cVYQwMUxKsXZkNE-1UOTidDchWRcPYq1KbdgyRT12pCgrfWbMhc_yH1BoJYQGlYuSB0
    Content-Type: text/xml
    Content-Length: 1338
    Server: Jetty(6.1.x)
    有没有好的办法获取TOKEN的值
    再次感谢