Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access item's properties in response message #386

Closed
rknetwork opened this issue Jan 16, 2017 · 13 comments
Closed

Access item's properties in response message #386

rknetwork opened this issue Jan 16, 2017 · 13 comments

Comments

@rknetwork
Copy link

How to correspond specific event from my database and response message?
Using 'examples/event/create.php' as example:

		foreach($events as $event) { // $event is array from my database
			if ($event['ewscreate'] == 1) {
				// Replace this with your desired start/end times and guests.
				$start = new DateTime($event['start']);
				$end = new DateTime($event['end']);

				// Build the event to be added.
				$event = new \jamesiarmes\PhpEws\Type\CalendarItemType();
				$event->Start = $start->format('c');
				$event->End = $end->format('c');
				$event->Subject = $event['subject'];

				// Set the event body.
				$event->Body = new \jamesiarmes\PhpEws\Type\BodyType();
				$event->Body->_ = $event['body'];
				$event->Body->BodyType = \jamesiarmes\PhpEws\Enumeration\BodyTypeType::TEXT;

				$event->myId = $event['id']; // MY ID GOES HERE

				// Add the event to the request. You could add multiple events to create more
				// than one in a single request.
				$request->Items->CalendarItem[] = $event;
			} else {
				// Blah
			}
		}

After successfully adding multiple events to Exchange server, I have no way of doing any further actions.

    foreach ($response_message->Items->CalendarItem as $item) {
        $id = $item->ItemId->Id;
        fwrite(STDOUT, "Created event $id\n");

        // Update MySQL telling that event successfully added;
        $my_id = $item->ItemId->myId; // MY ID IS NOT ACCESSIBLE
//				$query = "UPDATE schedules SET ewscreated=? WHERE id=?";
//				try { $stmt = $dbh->prepare($query); $stmt->execute(array(1, $my_id)); } catch(PDOException $ex) { echo 'Query failed: ' . $ex->getMessage(); exit; }

        print_r($item);
    }

So, what else can I do with successfully added event if all $item properties are empty?
I would like to update my MySQL Database telling that this event was successfully added.

jamesiarmes\PhpEws\Type\CalendarItemType Object
(
[AdjacentMeetingCount] =>
[AdjacentMeetings] =>
[AllowNewTimeProposal] =>
[AppointmentReplyTime] =>
[AppointmentSequenceNumber] =>
[AppointmentState] =>
[CalendarItemType] =>
[ConferenceType] =>
[ConflictingMeetingCount] =>
[ConflictingMeetings] =>
[DateTimeStamp] =>
[DeletedOccurrences] =>
[Duration] =>
[End] =>
[EndTimeZone] =>
[FirstOccurrence] =>
[IsAllDayEvent] =>
[IsCancelled] =>
[IsMeeting] =>
[IsOnlineMeeting] =>
[IsRecurring] =>
[IsResponseRequested] =>
[LastOccurrence] =>
[LegacyFreeBusyStatus] =>
[Location] =>
[MeetingRequestWasSent] =>
[MeetingTimeZone] =>
[MeetingWorkspaceUrl] =>
[ModifiedOccurrences] =>
[MyResponseType] =>
[NetShowUrl] =>
[OptionalAttendees] =>
[Organizer] =>
[OriginalStart] =>
[Recurrence] =>
[RecurrenceId] =>
[RequiredAttendees] =>
[Resources] =>
[Start] =>
[StartTimeZone] =>
[TimeZone] =>
[UID] =>
[When] =>
[Attachments] =>
[Body] =>
[Categories] =>
[ConversationId] =>
[Culture] =>
[DateTimeCreated] =>
[DateTimeReceived] =>
[DateTimeSent] =>
[DisplayCc] =>
[DisplayTo] =>
[EffectiveRights] =>
[ExtendedProperty] =>
[HasAttachments] =>
[Importance] =>
[InReplyTo] =>
[InternetMessageHeaders] =>
[IsAssociated] =>
[IsDraft] =>
[IsFromMe] =>
[IsResend] =>
[IsSubmitted] =>
[IsUnmodified] =>
[ItemClass] =>
[ItemId] => jamesiarmes\PhpEws\Type\ItemIdType Object
(
[ChangeKey] => DwAAABYAAACN1EJP8QgNR6s4hykKqlD7AAACWGyj
[Id] => AAMkADkyM2MyMGQ5LWRiNWYtNGJiMy04ZWYxLTE5OTA1ZjJmZjhlNwBGAAAAAAB+tS8kGeBSR5n5WFm+UJU7BwCN1EJP8QgNR6s4hykKqlD7AAAAAAA2AACN1EJP8QgNR6s4hykKqlD7AAACWF/EAAA=
)

[LastModifiedName] =>
[LastModifiedTime] =>
[MimeContent] =>
[ParentFolderId] =>
[ReceivedBy] =>
[ReceivedRepresenting] =>
[ReminderDueBy] =>
[ReminderIsSet] =>
[ReminderMinutesBeforeStart] =>
[ResponseObjects] =>
[Sensitivity] =>
[Size] =>
[StoreEntryId] =>
[Subject] =>
[UniqueBody] =>
[WebClientEditFormQueryString] =>
[WebClientReadFormQueryString] =>

)

@jamesiarmes
Copy link
Owner

In the future, please fill out the issue template that is provided in full.

During item create, the item id and change set are all that are returned. The responses should be in the same order as they were in the request, though I have not verified this. If you need more data about the item than is returned in the response, you would need to perform a GetItem request.

@rknetwork
Copy link
Author

Some examples with GetItem would be nice. Thanks.

@jamesiarmes
Copy link
Owner

All of the describe examples use GetItem.

@rknetwork
Copy link
Author

rknetwork commented Jan 17, 2017

GetItem is nowhere in /examples/event/create.php

@jamesiarmes
Copy link
Owner

All of the describe examples use GetItem.

Such as the event/describe example.

@rknetwork
Copy link
Author

rknetwork commented Jan 18, 2017

Wait, are you suggesting to do GetItem in a second request after creating them? I'm looking for the way of adding my own id to each item before the request and then retrieving my id in the response iteration..

@jamesiarmes
Copy link
Owner

If you need more data about the item than is returned in the CreateItem response, that's the only way to get it.

@rknetwork
Copy link
Author

rknetwork commented Jan 19, 2017

The responses should be in the same order as they were in the request, though I have not verified this.

Responses are NOT returned in the same order when using different types of Items (CalendarItem and CancelCalendarItem) in the same request, I verified this.

This makes impossible to use php-ews to further process events based on the response messages. You simply can't correspond your events with the response messages. WOW!

I hope this will change in the future.

@jamesiarmes
Copy link
Owner

This is not a limitation of php-ews but of Exchange Web Services. This library only wraps the EWS service providing objects and documentation that that PHP converts to/from XML based on the WSDL/XSD provided by Exchange. Have you attempted to verify whether or not the items in the response are in the same order as the request?

@rknetwork
Copy link
Author

rknetwork commented Jan 19, 2017

Have you attempted to verify whether or not the items in the response are in the same order as the request?

I said I did in my previous message.

Responses are NOT returned in the same order when using different types of Items (CalendarItem and CancelCalendarItem) in the same request, I verified this.

@jamesiarmes
Copy link
Owner

Ahh, sorry, I missed that, my apologies. My only suggestion then would be to make multiple requests. While I agree that it's inefficient, if you need to use the results of the requests (which you obviously would for CreatItem) that seems to be the only alternative. I would have expected Exchange to return each response in it's own message, but that appears to not be the case.

@rknetwork
Copy link
Author

This is what I figured. I got it to work with multiple requests. Efficiency is real bad, tons of extra code, separate arrays for each type.

Is there any possible way for response to contain more than just [Id] and [ChangeKey]? I really need to see my own event id in response... May be some dirty little tricks?

Thanks.

@jamesiarmes
Copy link
Owner

Not that I'm aware of, as CreateItemType does not contain an element for additional properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants