使用php-ews API获取通讯组列表中的联系人列表


Get a list of contacts in a distribution list using php-ews API

我使用PHP-EWS来获取联系人列表。此联系人列表是联系人根文件夹中的通讯组列表。

实际上我用的是这个:

$ews = new ExchangeWebServices($server, $username, $password);

$request = new EWSType_FindItemType();
$request->ItemShape = new EWSType_ItemResponseShapeType();
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;
$request->ContactsView = new EWSType_ContactsViewType();
$request->ContactsView->InitialName = 'a';
$request->ContactsView->FinalName = 'z';

$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
 $request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CONTACTS;
$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;
$response = $ews->FindItem($request);

我可以得到分发列表的ID,但是我无法得到其中的电子邮件地址。我怎么能得到它的stdClass对象或数组?

要获取联系人组内的联系人,需要使用ExpandDL操作,传递要扩展的联系人组的项目ID。我对php-ews库不够熟悉,无法提供示例代码,但希望这能给您指明正确的方向。关于SOAP请求的示例,请参阅此链接。