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 passCONTACTSasDistinguishedFolderIdin 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
SyncStateas 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@ MSDNIf you’d like to see example of
SyncFolderItemsyou 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 🙂