我正在使用https://github.com/Garethp/php-ews/库来访问我在 Exchange 服务器上的公共联系人文件夹。
这就是我创建联系人的方式。
$api = API::withUsernameAndPassword($server, $user, $pass);
$folder = $api->getFolderByDisplayName('Public', Enumeration\DistinguishedFolderIdNameType::PUBLICFOLDERSROOT);
$contattiTotali = $api->getFolderByDisplayName('Contacts', $folder->getFolderId());
$id=$contattiTotali->getFolderId()->getId();
$api->setFolderId($contattiTotali->getFolderId());
$api->createContacts(array(
'GivenName' => 'Homer',
'Surname' => 'Simpson',
'EmailAddresses' => array(
'Entry' => array('Key' => Enumeration\EmailAddressKeyType::EMAIL_ADDRESS_1, '_value' => 'h.simpson@gmail.com')
),
//Creating multiple entries
'PhoneNumbers' => array(
'Entry' => array(
array('Key' => Enumeration\PhoneNumberKeyType::HOME_PHONE, '_value' => '000'),
array('Key' => Enumeration\PhoneNumberKeyType::BUSINESS_PHONE, '_value' => '111'),
)
),
'PhysicalAddresses' => array(
'Entry' => array(
'Key' => Enumeration\PhysicalAddressKeyType::HOME,
'street' => '123 Street',
'city' => '123 City',
'state' => '123 State',
'countryOrRegion' => '123 Country',
'postalCode' => '12345',
)
),
));
实际上,该代码工作正常,但如果我多次执行它,它会复制联系人。
有没有办法在创建新联系人之前检查联系人(电子邮件地址是否足够好)是否已经存在?