我正在尝试使用php-ews和以下代码在Exchange中添加联系人:
$request = new EWSType_CreateItemType();
$request->SendMeetingInvitations = 'SendToNone';
$contact = new EWSType_ContactItemType();
$contact->GivenName = $updates['name'];
$contact->Surname = $updates['surname'];
if($updates['email'] != ""){
$email = new EWSType_EmailAddressDictionaryEntryType();
$email->Key = new EWSType_EmailAddressKeyType();
$email->Key->_ = EWSType_EmailAddressKeyType::EMAIL_ADDRESS_1;
$email->_ = $updates['email'];
// set the email
$contact->EmailAddresses = new EWSType_EmailAddressDictionaryType();
$contact->EmailAddresses->Entry[] = $email;
}
$contact->CompanyName = $updates['companyname'];
$contact->JobTitle = $updates['jobtitle'];
$contact->Birthday = $updates['birthday'];
$request->Items->Contact[] = $contact;
$response = $this->ews->CreateItem($request);其中$updates是我作为参数使用的字符串数组。(我跳过了includes,如果需要,请告诉我。)
现在,联系人已创建,一切正常,但生日事件不会在我的日历中自动创建。
所以,我想知道是否有一种简单的方法来完成这一点,除了明显的(非优雅的)手动创建它的方法。
先谢谢你,里卡多
发布于 2019-09-28 04:53:46
我可以像评论中预期的那样,使用正确格式的DateTime来解决这个问题。
$contact->Birthday = (new DateTime($updates['birthday']))->format(DATE_W3C);在dateTime元素的值中指定的时区可以采用三种形式。您可以在XML Schema Part 2: Datatypes Second Edition中阅读所有细节,但套用一下:
通用协调时间(
https://stackoverflow.com/questions/24385296
复制相似问题