EWS nusoap php请求FindItem操作

时间:2016-09-26 07:53:17

标签: php curl office365 exchangewebservices nusoap

我正在尝试编写一个简单的PHP脚本来从Microsoft EWS API获取日历数据:

  include_once('./lib/nusoap.php');

  $username = 'test@dopmain.com';
  $password = 'password';
  $endpoint = 'https://mex09.emailsrvr.com/ews/Services.wsdl';
  $wsdl = true;
  $soapclient = new nusoap_client($endpoint, $wsdl);

  $soapclient->setCredentials($username, $password, 'ntlm');

  $xml = '<FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"';
  $xml .= ' xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" Traversal="Shallow">';
  $xml .= '  <ItemShape>';
  $xml .= '    <t:BaseShape>IdOnly</t:BaseShape>';
  $xml .= '    <t:AdditionalProperties>';
  $xml .= '      <t:FieldURI FieldURI="message:From"/>';
  $xml .= '      <t:FieldURI FieldURI="item:Subject"/>';
  $xml .= '      <t:FieldURI FieldURI="message:IsRead"/>';
  $xml .= '      <t:FieldURI FieldURI="item:DateTimeReceived"/>';
  $xml .= '      <t:FieldURI FieldURI="calendar:Start"/>';
  $xml .= '      <t:FieldURI FieldURI="calendar:End"/>';
  $xml .= '      <t:FieldURI FieldURI="calendar:Location"/>';
  $xml .= '      <t:FieldURI FieldURI="task:Status"/>';
  $xml .= '      <t:FieldURI FieldURI="task:DueDate"/>';
  $xml .= '    </t:AdditionalProperties>';
  $xml .= '  </ItemShape>';
  $xml .= '  <IndexedPageItemView Offset="0" MaxEntriesReturned="5" BasePoint="Beginning"/>';
  $xml .= '  <ParentFolderIds>';
  $xml .= '    <t:DistinguishedFolderId Id="inbox"/>';
  $xml .= '  </ParentFolderIds>';
  $xml .= '</FindItem>';

  $operation = 'FindItem';
  $result = $soapclient->call($operation, $xml);
  var_dump($result);
  echo '<pre>'; print_r($result); echo '</pre>';

尽管此代码已被许多EWS博客确认!!!

  

我得到(bool)False作为$ result   并没有回应

我需要你的帮助。非常感谢!

1 个答案:

答案 0 :(得分:2)

我建议使用为EWS构建的库,例如garethp/php-ews