php-ews-master / response错误

时间:2014-01-08 16:42:16

标签: php curl libcurl soap-client

我正在尝试使用php-ews-master连接到交换服务器,而且我有一段时间都在苦苦挣扎。

使用 CURL_HTTP_VERSION_1_1 我收到错误消息:

  • Chunked-Encoded数据中的问题(3)。

如果我修改为 CURL_HTTP_VERSION_1_0 我从服务器得到了一个响应,但是响应中添加了很多字符(我想这些是因为chunked响应???)因此它不是一个有效的xml文件。

我正在尝试使用的代码:

$headers = array(
 'Method: POST',
 'Connection: Keep-Alive',
 'User-Agent: PHP-SOAP-CURL',
 'Content-Type: text/xml; charset=utf-8',
 'SOAPAction: "'.$action.'"',
 );
$this->ch = curl_init($location);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, $this->validate);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, $this->validate);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($this->ch, CURLOPT_POST, true );
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($this->ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($this->ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_setopt($this->ch, CURLOPT_USERPWD, $this->user.':'.$this->password);*

$response = curl_exec($this->ch);

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。 如果有任何人遇到同样的问题,只需添加以下行:

curl_setopt($ this-> ch,CURLOPT_SSLVERSION,3);