I am trying to add a contact in Exchange, using the php-ews and the following code:
$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);
Where $updates is an array of strings I have as a parameter.
(I skipped the includes, tell me if you need them.)
Now, the contact gets created and everything works, but the birthday event does not get created automatically in my calendar.
So, I would like to know if there's a simple way to have this done, except the obvious (non-elegant) way of creating it manually.
Thank you in advance,
Riccardo
Could solve this using DateTime in the right format as expected in the comments.
$contact->Birthday = (new DateTime($updates['birthday']))->format(DATE_W3C);
https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/time-zones-and-ews-in-exchange
The time zone specified in the value of dateTime elements can take three forms. You can read all the details in XML Schema Part 2: Datatypes Second Edition, but to paraphrase:
Universal Coordinated Time (UTC): Specified by 'Z'. For example, 2014-06-06T19:00:00.000Z
Specific time zone: Specified by '+' or '-' followed by hours and minutes. For example, 2014-06-06T19:00:00.000-08:00
No time zone: Specified by the absence of any time zone. For example, 2014-06-06T19:00:00.000
Related
I am using devbay's eBay SDK for PHP.
By default SoldReport is returning the last 30 days.
I'm trying to filter the date range to specify one-day/24 hour period.
I'm assuming I need to include a date range filter somewhere in the StartDownloadJobRequest call.
$startDownloadJobRequest = new BulkDataExchange\Types\StartDownloadJobRequest();
$startDownloadJobRequest->downloadJobType = 'SoldReport';
$startDownloadJobRequest->UUID = uniqid();
$startDownloadJobRequest->downloadRequestFilter = new BulkDataExchange\Types\DownloadRequestFilter();
$startDownloadJobRequest->downloadRequestFilter->activeInventoryReportFilter = $activeInventoryReportFilter;
I tried CreateTimeFrom and CreateTimeTo but received an Unknown property CreateTimeFrom error, so I do not believe I can use that for this request.
Anyone know how to filter date range in reports?
edit:
So it looks like startTime and endTime is apart of DownloadRequestFilter
DownloadRequestFilter DateTime
I thought something like this would work..
$datefilter = new BulkDataExchange\Types\DateFilter();
$datefilter->startTime = new DateTime('22-10-2016');
$datefilter->endTime = new DateTime('23-10-2016');
//
$startDownloadJobRequest->downloadRequestFilter->dateFilter = $datefilter;
but this doesn't work and I still get all results.
I am trying to create a recurring calendar event with php-ews and the documentation is very limited in this aspect. I have got what is below so far I just can not find out how to have it repeat say every Monday and Wednesday. Can anyone who has done this before or knows how help me out?
$request->Items->CalendarItem->Recurrence = new Type\RecurrenceType();
$request->Items->CalendarItem->Recurrence->WeeklyRecurrence = new Type\IntervalRecurrencePatternBaseType();
$request->Items->CalendarItem->Recurrence->NumberedRecurrence = new Type\NumberedRecurrenceRangeType();
$request->Items->CalendarItem->Recurrence->NumberedRecurrence->NumberOfOccurrences = 2;
$request->Items->CalendarItem->Recurrence->NumberedRecurrence->StartDate = //start date here;
I've successfully used this...
// Set up recurrence days
$request->Items->CalendarItem->Recurrence = new EWSType_RecurrenceType();
$request->Items->CalendarItem->Recurrence->WeeklyRecurrence = new EWSType_IntervalRecurrencePatternBaseType();
$request->Items->CalendarItem->Recurrence->WeeklyRecurrence->Interval = 1;
$request->Items->CalendarItem->Recurrence->WeeklyRecurrence->DaysOfWeek = new EWSType_ArrayOfStringsType();
$request->Items->CalendarItem->Recurrence->WeeklyRecurrence->DaysOfWeek = array(EWSType_DayOfWeekType::MONDAY, EWSType_DayOfWeekType::WEDNESDAY, EWSType_DayOfWeekType::FRIDAY);
// Specify recurrence start and end
$request->Items->CalendarItem->Recurrence->EndDateRecurrence = new EWSType_EndDateRecurrenceRangeType();
$request->Items->CalendarItem->Recurrence->EndDateRecurrence->EndDate = '2014-05-30';
$request->Items->CalendarItem->Recurrence->EndDateRecurrence->StartDate = '2014-05-14';
Looks like you're just missing the DaysOfWeek array item. Adjust your array as needed based on the days you'd like the meeting to occur, and of course set your own start and end dates as well. I believe the Interval item would be equivalent to 1=every week, 2=every other week, etc. but i have not tested that.
Hi guys :) I am trying to take all meeting from resource meeting box, but when i try to take subject like this $subject = $event->Subject it displays name by whom meeting was created. $request->ParentFolderIds->DistinguishedFolderId->Mailbox->EmailAddress = "mail#domain.com" This is code how i select resource meeting box.
I want to take meeting subject by other way and i will be glad if you will help me :)
$request = new EWSType_FindItemType();
// Use this to search only the items in the parent directory in question or use ::SOFT_DELETED
// to identify "soft deleted" items, i.e. not visible and not in the trash can.
$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;
// This identifies the set of properties to return in an item or folder response
$request->ItemShape = new EWSType_ItemResponseShapeType();
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::DEFAULT_PROPERTIES;
// Define the timeframe to load calendar items
$request->CalendarView = new EWSType_CalendarViewType();
$request->CalendarView->StartDate ='2014-03-28T15:00:00+04:00';// an ISO8601 date e.g. 2012-06-12T15:18:34+03:00 "Y-m-d\TH:i:sO"
$request->CalendarView->EndDate = '2015-03-28T15:00:00+04:00';// an ISO8601 date later than the above "Y-m-d\TH:i:sO"
// Only look in the "calendars folder"
$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CALENDAR;
$request->ParentFolderIds->DistinguishedFolderId->Mailbox->EmailAddress = "meetingroom#gcfund.ge";
// Send request
$response = $ews->FindItem($request);
// Loop through each item if event(s) were found in the timeframe specified
if ($response->ResponseMessages->FindItemResponseMessage->RootFolder->TotalItemsInView > 0){
$events = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->CalendarItem;
// $db_selected = mysql_select_db('meeting_room',$con);
// $res=mysql_query("SELECT ID FROM meeting");
// while($row = mysql_fetch_array($res)){
// echo $row['ID'];
// echo "<br>";
// }
foreach ($events as $event){
$id = $event->ItemId->Id;
$change_key = $event->ItemId->ChangeKey;
$start = $event->Start;
$end = $event->End;
$subject = $event->Subject;
$location = $event->Location;
This subject displays by whom meeting was created. I want this info too but i want Subject too.. Please Help :)
This is an issue with Exchange (not your code, or the PHP library, or EWS)
Several blogs, such as this one: http://www.slipstick.com/exchange/cmdlets/meeting-organizers-name-appears-in-subject-line/ indicate that you can perform some PowerShell commands to change the Exchange server configuration. Note that if you change the configuration, it will apply for all new meetings/appointments added after the configuration change (existing meetings/appointments will stay as-is).
If you don't have PowerShell access to the Exchange server but do have administrator access via another system, you might be able to achieve the same configuration change through the interface for that system. For example, on a Parallels hosted exchange system, login to Parallels as administrator, go to Exchange, go to Resource mailboxes, edit the room resource, and untick the "Add organizer to subject" checkbox under the "Resource scheduling" tab. As far as I can tell, this just performs the same PowerShell action behind the scenes.
There may be similar options in other systems (e.g. Office 365) though I haven't looked into that.
Having said all that, I have found that making this configuration change didn't help in my case: I created a new meeting against a room resource, however the subject ended up as "" (empty string) instead of the correct subject or the organiser's name. In any case, give the configuration change a try, as other people have apparently had success with it.
As part of a PHP webapp I have MySQL contacts table. It is integrated throughout the app, allowing you add a contact, edit a contact or add a contact as a relation to another table. However, currently it is self-contained. The company would like it to sync with Exchange, so that contacts added to Exchange will show up on the webapp and contacts added on the webapp will show up through Exchange.
So I have two problems: 1) communicating with Exchange 2) syncing with Exchange.
As far as the basic communication goes, it looks like this library will be able to manage it https://github.com/jamesiarmes/php-ews. However, I am quite lost as to how to manage syncing and don't where to start.
The build-in way to sync items is via function called SyncFolderItems. Basically to Exchange everything, including contacts is a folder, so you'll just pass CONTACTS as DistinguishedFolderId in your sync request.
The sync works by donloading all the items for given account in batches of max 512 elements and after each batch it gives you SyncState as a refernce point for Exchange to know where you left off. So it gives you ability to do incremental sync.
Now, that's one way of course, meaning Exchange -> Your DB. The other way it aeound you should preform atomic updates/request - the moment you change/add/delete item form your db you should issue adequate request to Exchange server to keep data in sync, elese it'll be overwritten on your next SyncFolderItems.
You can read up more on SyncFolderItems # MSDN
If you'd like to see example of SyncFolderItems you can take a look # python version of EWSWrapper, it's been added in recently. Although it's python, you can still get the basic idea how to construct the request / handle response.
Hope this helps :)
I am aware that this topic is pretty old. However, for future reference find a solution below. It is using the above-mentioned library php-ews.
I have also just added this to the official php-ews wiki: https://github.com/jamesiarmes/php-ews/wiki/Calendar:-Synchronization
// Define EWS
$ews = new ExchangeWebServices($host, $username, $password, $version);
// fill with string from last sync
$sync_state = null;
$request = new EWSType_SyncFolderItemsType;
$request->SyncState = $sync_state;
$request->MaxChangesReturned = 512;
$request->ItemShape = new EWSType_ItemResponseShapeType;
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;
$request->SyncFolderId = new EWSType_NonEmptyArrayOfBaseFolderIdsType;
$request->SyncFolderId->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType;
$request->SyncFolderId->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CALENDAR;
$response = $ews->SyncFolderItems($request);
$sync_state = $response->ResponseMessages->SyncFolderItemsResponseMessage->SyncState;
$changes = $response->ResponseMessages->SyncFolderItemsResponseMessage->Changes;
// created events
if(property_exists($changes, 'Create')) {
foreach($changes->Create as $event) {
$id = $event->CalendarItem->ItemId->Id;
$change_key = $event->CalendarItem->ItemId->ChangeKey;
$start = $event->CalendarItem->Start;
$end = $event->CalendarItem->End;
$subject = $event->CalendarItem->Subject;
}
}
// updated events
if(property_exists($changes, 'Update')) {
foreach($changes->Update as $event) {
$id = $event->CalendarItem->ItemId->Id;
$change_key = $event->CalendarItem->ItemId->ChangeKey;
$start = $event->CalendarItem->Start;
$end = $event->CalendarItem->End;
$subject = $event->CalendarItem->Subject;
}
}
// deleted events
if(property_exists($changes, 'Delete')) {
foreach($changes->Delete as $event) {
$id = $event->CalendarItem->ItemId->Id;
$change_key = $event->CalendarItem->ItemId->ChangeKey;
$start = $event->CalendarItem->Start;
$end = $event->CalendarItem->End;
$subject = $event->CalendarItem->Subject;
}
}
I am trying to use the Zend_Gdata_Calendar library to create a new event on the Google Calendar API and am struggling to work out how to set the visibility - has anyone any ideas how to actually do it?
The construct of my class has
$this->calendar_client = Zend_Gdata_ClientLogin::getHttpClient($this->user_name, $this->password, Zend_Gdata_Calendar::AUTH_SERVICE_NAME);
Where the user_name and pass_word are the login details for an account which is able to write to the calendar. The following works
$gdataCal = new Zend_Gdata_Calendar($this->calendar_client);
$newEvent = $gdataCal->newEventEntry();
$newEvent->title = $gdataCal->newTitle($title);
$newEvent->where = array($gdataCal->newWhere($where));
$newEvent->content = $gdataCal->newContent($content);
$newEvent->visibility = 'private';
$when = $gdataCal->newWhen();
$when->startTime = $start_time;
$when->endTime = $end_time;
$newEvent->when = array($when);
$createdEvent = $gdataCal->insertEvent($newEvent,"https://www.google.com/calendar/feeds/{$email}/private/full");
($title, $where, and $content are text strings passed into the function)
However the visibility doesn't seam to get used.
I have tried the visibility shown above and also each of the following,
$newEvent->setVisibility($gdataCal->newVisibility('private'));
$newEvent->setVisibility($gdataCal->newVisibility(true));
$newEvent->setVisibility($gdataCal->newVisibility(false));
And while these all work (i.e. an event is created at the correct time) the private flag is never set!
Answering my own question you need to use a URI for it!
$newEvent->visibility = $gdataCal->newVisibility("http://schemas.google.com/g/2005#event.public");
$newEvent->visibility = $gdataCal->newVisibility("http://schemas.google.com/g/2005#event.private");