小编Dar*_*ine的帖子

使用PHP和cURL访问Exchange Web服务

你好,

我目前正在编写一个客户端来访问Microsoft Exchange服务器并从中读取联系人,约会等.

经过几天的搜索,我已经能够通过PHP的Soap客户端和自定义HTTPS流包装器连接到EWS.这个网站在这一点上给了我很大的帮助.

使用XAMPP在我的Windows 7机器上一切正常

现在我将我的项目上传到Debian 6.0 Squeeze开发机器,它与我的Windows机器完全相同,关于web服务器,php设置,mysql设置等等,但它不再适用了

debian机器可以毫无问题地解析和ping交换服务器

我将实际问题解决到了一定程度,其中cURL无法检索EWS的WSDL文件

它始终收到空响应和401(未授权)状态代码

我使用的凭据是正确的,相同的凭据在我的Windows机器上工作

我提取了有问题的代码并尝试独立运行它,它看起来像这样:

    echo "Trying to get https://".$cfg[ 'Exchange.Server' ]."/EWS/Services.wsdl<br>";
    $curl = curl_init( 'https://'.$cfg[ 'Exchange.Server' ].'/EWS/Services.wsdl' );
    curl_setopt( $curl, CURLOPT_RETURNTRANSFER,     true );
    curl_setopt( $curl, CURLOPT_HTTP_VERSION,       CURL_HTTP_VERSION_1_1 );
    curl_setopt( $curl, CURLOPT_HTTPAUTH,           CURLAUTH_NTLM );
    curl_setopt( $curl, CURLOPT_USERPWD,            $cfg[ 'Exchange.User' ].':'.$cfg[ 'Exchange.Password' ] );
    curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER,     false );
    curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST,     false );

    echo '<pre>';
    $response = curl_exec( $curl );
    $info = curl_getinfo( $curl );

    var_dump( $info );
    var_dump( …
Run Code Online (Sandbox Code Playgroud)

php curl ntlm exchangewebservices http-status-code-401

12
推荐指数
1
解决办法
2万
查看次数