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
FreeBusy REsponse status #167
Comments
Here is some code I use to check for the existence of an email account. It uses the GetUserAvailability() method which I think is what you are looking for. I don't care about the actual free/busy status, so I only check for errors and throw an Exception if there is one. This code uses my own PSR-0 branch (with namespaces), so you'll have to convert it to use the non-namespaced style if you want to use it with the plain php-ews. $requestor_email = 'someone@mail.com';
$check_sub_req = new EWSType\GetUserAvailabilityRequestType();
// Set the mailbox of the person you are looking up
$check_sub_req->MailboxDataArray = new EWSType\ArrayOfMailboxData();
$check_sub_req->MailboxDataArray->MailboxData = new EWSType\MailboxData();
$check_sub_req->MailboxDataArray->MailboxData->Email = new EWSType\EmailAddress();
$check_sub_req->MailboxDataArray->MailboxData->Email->Address = $requestor_email;
$check_sub_req->MailboxDataArray->MailboxData->AttendeeType = 'Required';
$check_sub_req->MailboxDataArray->MailboxData->ExcludeConflicts = false;
// This time zone data will likely be different for you
$check_sub_req->TimeZone = new EWSType\SerializableTimeZone();
$check_sub_req->TimeZone->Bias = 480;
$check_sub_req->TimeZone->StandardTime = new EWSType\SerializableTimeZoneTime();
$check_sub_req->TimeZone->StandardTime->Bias = 0;
$check_sub_req->TimeZone->StandardTime->Time = '02:00:00';
$check_sub_req->TimeZone->StandardTime->DayOfWeek = EWSType\DayOfWeekType::SUNDAY;
$check_sub_req->TimeZone->StandardTime->DayOrder = 1;
$check_sub_req->TimeZone->StandardTime->Month = 11;
$check_sub_req->TimeZone->DaylightTime = new EWSType\SerializableTimeZoneTime();
$check_sub_req->TimeZone->DaylightTime->Bias = -60;
$check_sub_req->TimeZone->DaylightTime->Time = '02:00:00';
$check_sub_req->TimeZone->DaylightTime->DayOfWeek = EWSType\DayOfWeekType::SUNDAY;
$check_sub_req->TimeZone->DaylightTime->DayOrder = 2;
$check_sub_req->TimeZone->DaylightTime->Month = 3;
// $form_start_dt and $form_end_dt are DateTime objects containing the
// start and end times you want to search within
$check_sub_req->FreeBusyViewOptions = new EWSType\FreeBusyViewOptionsType();
$check_sub_req->FreeBusyViewOptions->TimeWindow = new EWSType\Duration();
$check_sub_req->FreeBusyViewOptions->TimeWindow->StartTime = $form_start_dt->format('Y-m-d\TH:i:s');
$check_sub_req->FreeBusyViewOptions->TimeWindow->EndTime = $form_end_dt->format('Y-m-d\TH:i:s');
$check_sub_req->FreeBusyViewOptions->MergedFreeBusyIntervalInMinutes = 30;
$check_sub_req->FreeBusyViewOptions->RequestedView = 'MergedOnly';
// Send the request to the server
$check_sub_resp = $ews->GetUserAvailability($check_sub_req);
// Check the response
if ($check_sub_resp->FreeBusyResponseArray->FreeBusyResponse->ResponseMessage->ResponseCode == 'ErrorMailRecipientNotFound')
throw new \Exception("$requestor_email is not a valid email account");
elseif ($check_sub_resp->FreeBusyResponseArray->FreeBusyResponse->ResponseMessage->ResponseCode != 'NoError')
throw new \Exception("An error occurred while validating Requestor Email account: " . $check_sub_resp->FreeBusyResponseArray->FreeBusyResponse->ResponseMessage->MessageText); |
hi JeremyBuchmann i get the response as below. stdClass Object
I dont get any status as free or busy. Thanks in advance... |
@scvinodkumar : You are getting the free/busy data in the "[MergedFreeBusy] => 00000011" element. The data is encoded. Since I don't use this data in my project, I can't give you a full explanation, but I can point you to the Microsoft EWS documentation on FreeBusyView: http://msdn.microsoft.com/en-us/library/aa565398%28v=exchg.140%29.aspx and MergedFreeBusy: http://msdn.microsoft.com/en-us/library/aa566048%28v=exchg.140%29.aspx |
Hello , Thanks for the code. But i have a question. My application put a appointement for a room. Before that, i need to look if the room as available. I dont understand the timezone , bias , daylight dayorder....etc // This time zone data will likely be different for you For my exemple i have an appointement at 15h to 16h30 and suppose i want to check between this date intervale $dt_start = DateTime::createFromFormat("Y-m-d H:i", "2016-03-18 14:00"); $check_sub_req->FreeBusyViewOptions->TimeWindow->StartTime = $dt_start->format('Y-m-d\TH:i:s'); I dont know why but if i choose 14h00 to 17h00, php-ews will check between 17h00 to 20h00... So i patched the problem with a 3h substract of my inital hour. $dt_start = DateTime::createFromFormat("Y-m-d H:i", "2016-03-18 14:00"); If i do this patch, php ews return me the good MergedFreeBusy [MergedFreeBusy] => 002220 Help me because i think i do the wrong thing thanks |
@joellacas The purpose of all of the TimeZone stuff is exactly that - it's setting your timezone and when DST starts and ends. In the example code provided above, you're setting your timezone to PST/PDT - California time, which is what the standard examples used. This is 3 hours off of EST/EDT, which I suspect is what you're wanting to use. Rather than changing your date interval, and having all of the dates/times you're looking at appear wrong during debugging, you simply needed to change: Hope this helps - it wasn't immediately obvious to me either when doing my initial debugging (though it would have been if I had looked closer). |
Hi
how to retrieve free busy status of a person for a particular time interval. It would be great if u share the code. I need in php.
Thanks for your help !!!!
The text was updated successfully, but these errors were encountered: