我正在使用 EWS(Exchange Web 服务)从我的 Exchange 2013 测试服务器访问数据。我正在使用 PHP 和(有些过时的)php-ews 存储库来执行此操作:github-jamesiarmes-php-ews和更新且支持作曲家的版本:github-deakin-php-ews
我可以按照“jamesiarmes”的 wiki 中所述对 Exchange 服务进行基本调用,但是当我尝试使用 GroupBy 方法时遇到了一些麻烦:如何:在 Exchange 中使用 EWS 执行分组搜索
正如您在 How-to 指南的 XML 响应中看到的那样,通常该<Groups>
元素应包含零个或多个<GroupItems>
然后将包含项目(在我的情况下为 CalendarItems)。但是我从测试服务器返回的是<Group>
元素,而不是<GroupItems>
导致我的 $response 对象不完整。
我使用的代码:
$request = new FindItemType();
$request->Traversal = ItemQueryTraversalType::SHALLOW;
$request->ItemShape = new ItemResponseShapeType();
$request->ItemShape->BaseShape = DefaultShapeNamesType::ALL_PROPERTIES;
// Define the time frame to load calendar items
$request->CalendarView = new CalendarViewType();
$request->CalendarView->StartDate = '2014-01-12T15:18:34+03:00';
$request->CalendarView->EndDate = '2015-01-12T15:18:34+03:00';
// Find events from a certain folders
$request->ParentFolderIds = new NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->FolderId = new FolderIdType();
$request->ParentFolderIds->FolderId->Id = $calendarFolderUID;
// Group the events by date
$request->GroupBy = new GroupByType();
$request->GroupBy->Order = 'Ascending';
$request->GroupBy->FieldURI = new FieldURIOrConstantType();
$request->GroupBy->FieldURI->FieldURI = 'calendar:Start';
$request->GroupBy->AggregateOn = new AggregateOnType();
$request->GroupBy->AggregateOn->Aggregate = 'Minimum';
$request->GroupBy->AggregateOn->FieldURI = new FieldURIOrConstantType();
$request->GroupBy->AggregateOn->FieldURI->FieldURI = 'calendar:End';
$response = $this->soapService->FindItem($request);
这是var_dump()
来自$response
:
object(stdClass)#685 (1) {
["ResponseMessages"]=>
object(stdClass)#690 (1) {
["FindItemResponseMessage"]=>
object(stdClass)#714 (3) {
["ResponseCode"]=>
string(7) "NoError"
["ResponseClass"]=>
string(7) "Success"
["RootFolder"]=>
object(stdClass)#715 (3) {
["Groups"]=>
object(stdClass)#716 (0) {
}
["IncludesLastItemInRange"]=>
bool(true)
["TotalItemsInView"]=>
int(4)
}
}
}
}
我设法使用__getLastResponse()
(PHP 文档)收集 XML 响应,发现它确实获得了所有想要的项目,但是在<Group>
元素中而不是<GroupItems>
在 SoapClient 中为<Groups>
元素返回一个空对象。
现在我想知道问题出在哪里:
- 操作指南是否已过时?我在 EWS 的其他文档中没有找到对这个
<Group>
元素的任何引用,所以我认为这不是问题。 - 我的 Exchange 服务器是在使用另一个 XML 架构还是很奇怪?
- php-ews 模式是否已过时?我应该用最终的解决方案来分叉“deakin”回购吗?
我已经找到了一种通过调整 php-ews 模式来使其工作的方法,但是如果问题出在我的测试服务器上,我就不需要费心制作一个 fork 了……我也会在下面发布我当前的解决方案。
我将不胜感激对此的任何意见....