下面代码怎么修改可以获得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;
}
{
$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;
}
解决方案 »
- 如何编写不匹配指定单词的正则表达式?
- PHP Error: Could not connect to database. Please try again later.
- 问一个小菜问题?
- 各位请进: 菜鸟有小问题.
- 如何用php实现在线人数统计
- 请问,用perl编写cgi,在一个表单中实现文件上传和复选择列表的方法?
- 团队招收人员
- 请问php中上传
- php下img标签正则怎么琯
- PHP调用MySQL存储过程,第一次调用成功,刷新页面报Commands out of sync; you can't run this command 错误
- 关于button提交数据问题注意不是submit!!!
- 小问题!
用print_r($response);打印出返回内容就知道了。
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<MethodResponse>
<ErrorCode>0</ErrorCode>
</MethodResponse>返回上面这样的数据 没有header 郁闷呀
curl_setopt($ch, CURLOPT_HEADER, true);
才会在输出中包含header
HTTP/1.1 200 OK
TOKEN: Ciyvab0tregdVsBtboIpeChe4G6uzC1v5_-SIxmvSLIHtcrLGXASvkJBsWFG_cVYQwMUxKsXZkNE-1UOTidDchWRcPYq1KbdgyRT12pCgrfWbMhc_yH1BoJYQGlYuSB0
Content-Type: text/xml
Content-Length: 1338
Server: Jetty(6.1.x)
有没有好的办法获取TOKEN的值
再次感谢