Comments (20)
Hi. The first thing to do would be to get the folder ID of your public folder. You can do this through getFolderByDistinguishedId($distinguishedId)
, if it's a distinguished folder, getChildrenFolders($parentFolderId = 'root', $options = array())
if you've got it's parent folder or getFolderByDisplayName($folderName, $parentFolderId = 'root', $options = array())
if you only have a Folder Name. All of these should return a folderId. Then you set the folder ID to the calendar. So the complete example would look something like
<?php
use garethp\ews\API;
$api = API::withUsernameAndPassword('server', 'username', 'password');
//Get the default calendar
$calendar = $api->getCalendar();
//Do whatever it is you need to do to get the folderId here
$folderId = $api->getFolderByDisplayName('Name', $parentFolderId);
//Get a calendar by the name 'Test'
$calendar->setFolderId($folderId);
//Get the initial list of Items
$changes = $calendar->listChanges();
//We use this to keep track of when we last asked for items
$syncState = $changes->getSyncState();
//Get a list of changes since we last asked for them
$changesSinceLsatCheck = $calendar->listChanges($syncState);
How you get the folder ID I'm not 100% sure on. I'm not sure what your setup is or what a "public folder" is exactly, or how to work with them
from php-ews.
On doing a little bit of research, if you go down the getFolderByDisplayName
or getChildrenFolders
route, you should use 'publicfoldersroot'
as the parentFolderId
. So maybe something like this
<?php
use garethp\ews\API;
use garethp\ews\API\Enumeration;
$api = API::withUsernameAndPassword('server', 'username', 'password');
//Get the default calendar
$calendar = $api->getCalendar();
//Do whatever it is you need to do to get the folderId here
$folderId = $api->getFolderByDisplayName('My Public Folder', Enumeration\DistinguishedFolderIdNameType::PUBLICFOLDERSROOT);
//Get a calendar by the name 'Test'
$calendar->setFolderId($folderId);
//Get the initial list of Items
$changes = $calendar->listChanges();
//We use this to keep track of when we last asked for items
$syncState = $changes->getSyncState();
//Get a list of changes since we last asked for them
$changesSinceLsatCheck = $calendar->listChanges($syncState);
from php-ews.
Hi, thanks for your help. It works getting the folder ID with your 2. example. However if I call listChanges
, I get the following error:
'SyncFolderItems' has an invalid child element 'SyncScope' in Namespace 'http://schemas.microsoft.com/exchange/services/2006/messages'.
from php-ews.
That's... very odd. What version of Exchange are you running?
from php-ews.
I'm using Exchange 2007 SP3, for ews to work I had to set version to Exchange2007_SP1
.
from php-ews.
That's probably a good idea. I'd suggest setting it to Exchange2007_SP3
just to be safe, or upgrading to Exchange 2010 or Exchange 2013, but it's good to see that you managed to solve it
from php-ews.
Is your question answered?
from php-ews.
Sorry for not being clear. The error still appears. EWS did not work at all with Exchange2007_SP3
, although I run SP3. Only Exchange2007_SP1
works to get a connection. Unfortunately upgrading is no option, since the server is too old.
from php-ews.
Hm... maybe SyncScope isn't supported with 2007. Can you replace $changes = $calendar->listChanges();
with
$request = array(
'ItemShape' => array('BaseShape' => 'IdOnly'),
'SyncFolderId' => array('FolderId' => $calendar->getFolderId()->toXmlObject()),
'MaxChangesReturned' => '10'
);
if ($syncState != null) {
$request['SyncState'] = $syncState;
$request['ItemShape']['BaseShape'] = 'AllProperties';
}
$request = array_replace_recursive($request, $options);
$request = Type::buildFromArray($request);
$changes = $this->getClient()->SyncFolderItems($request);
And see what happens?
from php-ews.
You were right, not requesting SyncScope works. Is it possible to change that in the API for Exchange 2007? It also would be useful to set the MaxChangesReturned
as an argument.
from php-ews.
I'll mark it as a note, and see if I can make it in to a release some time in the next month or so. To be honest, I'm not 100% sure what would be a good way of making certain exclusions based on version.
As for the MaxChangesReturned
, I may end up making it an argument. Or at least increasing that to 100. At the moment you can change it by doing something similar to
$calendar->listChanges($syncState, [
'MaxChangesReturned' => $number
]);
from php-ews.
I understand that making exclusion based on version is not easy and can cause a 'mess' in the API. However since I use Exchange 2007, it would be nice if support continues. This library is a great development of the original library.
from php-ews.
Definitely support will continue, it's just more of a case of figuring out how to handle the mess. I do intend to support Exchange 2007 going forward, it's just a case of how to do that cleanly, if you know what I mean. Could you also try this in the meantime?
$calendar->listChanges($syncState, [
'SyncScope' => null
]);
from php-ews.
I'll add a quick messy way of removing it for Exchange 2007 in the next release. I just have an issue open at the moment about my current dev-master that I want to get resolved before I make another release.
from php-ews.
Setting 'SyncScope' => null
works. This is a good workaround for me.
from php-ews.
Cheers. Next release I'll also have an example on getting public folder ID's since this worked for you
from php-ews.
Just a little note, getFolderId
was missing in the example.
$folderId = $api->getFolderByDisplayName('My Public Folder', Enumeration\DistinguishedFolderIdNameType::PUBLICFOLDERSROOT)->getFolderId();
from php-ews.
Oh, thanks! I forgot that that function returns the whole folder as opposed to the FolderId! Will make note of that when I make the example
from php-ews.
Hi there
I've implemented a middleware pattern that I'm testing out, and it should auto-remove the SyncScope
for you. I was wondering if you'd be able to pull down dev-master
and give it a test, to make sure that it works as expected.
Thanks,
Gareth
from php-ews.
I've just tested version 0.9 and it worked for me. Thanks!
from php-ews.
Related Issues (20)
- Upgrade from jamesiarmes -> garethp php-ews HOT 1
- Create a contact
- internetMessageHeaders HOT 1
- BUG FreeBusyResponse array HOT 1
- toRecipients getting null values for inplace archive mails
- Update Mail Item -> Categorize Email HOT 1
- PHP 8.2 - Deprecated dynamic properties HOT 5
- Oauth is not working with Exchange 2013
- Issue with using toRecipients property in EWS restriction HOT 2
- Daylight Savings
- How to get medias appointment
- Update contact with ExtendedProperty
- Exceptions
- Set a calendar event with custom identifier, so that I can (later on) GET an event by the same identifier HOT 3
- Change "busy" status for event. HOT 2
- Checking if an item exists (by $itemId and $changeKey) results in FATAL ERROR if the object is not found - How to handle this? HOT 1
- Also delete recurring events when master event is deleted? HOT 1
- getLegacyFreeBusyStatus() does not return WorkingElsewhere HOT 1
- Authentication error after Exchange Extended Protection was enabled HOT 2
- Add Kerberos support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-ews.