Trying to implement MS Exchange api CalendarItem creation useng jamesiarmes/php-ews. Was able to create simple events and events with partisipants, but when i tried to add recurrence - nothing works.
Saw similar questions - they are outdated and of no use anymore.
This is what i have:
public function createCalendarItem(array $eventData) {
$request = new CreateItemType();
$request->Items = new NonEmptyArrayOfAllItemsType();
//Event accembly---------------------------
$event = new CalendarItemType();
$event->Start = $eventData['startTime'];
$event->End = $eventData['endTime'];
$event->Subject = $eventData['subject'];
$event->Location = $eventData['location'];
//In case event is recurring---------------
if ($eventData['isRecurring']) {
$event->CalendarItemType = CalendarItemTypeType::RECURRING_MASTER;
$recurrence = new RecurrenceType();
switch ($eventData['recurrenceDetails']['type']) {
case 'daily':
$recurrence->DailyRecurrence = new DailyRecurrencePatternType();
$event->Recurrence = $recurrence;
break;
case 'weekly':
$weeklyRecurrenceInfo = new WeeklyRecurrencePatternType();
$weeklyRecurrenceInfo->Interval = $eventData['recurrenceDetails']['interval'];
$weeklyRecurrenceInfo->DaysOfWeek = new ArrayOfStringsType();
$weeklyRecurrenceInfo->DaysOfWeek = [DayOfWeekType::THURSDAY];
$recurrence->WeeklyRecurrence = $weeklyRecurrenceInfo;
$event->Recurrence = $recurrence;
break;
case 'monthly':
break;
case 'yearly';
break;
case 'custom':
break;
}
}
//-----------------------------------------
$eventBody = new BodyType();
$eventBody->_ = $eventData['description'];
$eventBody->BodyType = BodyTypeType::TEXT;
$event->Body = $eventBody;
// In case new event should have a list of partisipants
if(!empty($eventData['attendees'])) {
$event->RequiredAttendees = new NonEmptyArrayOfAttendeesType();
$event->RequiredAttendees->Attendee = array();
foreach ($eventData['attendees'] as $guest) {
$attendee = new AttendeeType();
$attendee->Mailbox = new EmailAddressType();
$attendee->Mailbox->EmailAddress = $guest['email'];
$attendee->Mailbox->Name = $guest['name'];
$attendee->Mailbox->RoutingType = RoutingType::SMTP;
$event->RequiredAttendees->Attendee[] = $attendee;
}
}
$request->Items->CalendarItem[] = $event;
//--------------------------------------------
$request->SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType::SEND_TO_NONE;
$response = $this->client->CreateItem($request);
return $response;
}
Can anyone explain me, what am i doing wrong?
'daily' option just causes "Request is invalid":
local.ERROR: The request is invalid. {"userId":11,"exception":"[object] (SoapFault(code: 0 faultcode: a:ErrorInvalidRequest detail: {\"ResponseCode\":\"ErrorInvalidRequest\",\"Message\":\"The request is invalid.\"}): The request is invalid. at /var/www/html/vendor/php-ews/php-ews/src/Client.php:1631)
on line $response = $this->client->CreateItem($request);
But there is not a single property to be set in DailyRecurrencePatternType, so i don't get what could be a cause.
'weekly' option causes response to be:
+CreateItemResponseMessage: array:1 [▼
0 => jamesiarmes\PhpEws\Response\ItemInfoResponseMessageType {#2516 ▼
+DescriptiveLinkKey: 0
+MessageText: "Set action is invalid for property."
+MessageXml: {#2495 ▼
+"any": array:1 [▼
"FieldURI" => jamesiarmes\PhpEws\Type\PathToUnindexedFieldType {#2493 ▼
+FieldURI: "calendar:CalendarItemType"
}
]
}
+ResponseClass: "Error"
+ResponseCode: "ErrorInvalidPropertySet"
+Items: jamesiarmes\PhpEws\ArrayType\ArrayOfRealItemsType {#2517 ▶}
}
]
But if i get it right, it says that event type itself defined wrong. How could that be?