Coder Social home page Coder Social logo

Comments (5)

Garethp avatar Garethp commented on August 10, 2024

Huh, weird. Can you show me your code where you try do do the tdwo syncs with different SyncStates?

from php-ews.

pjwj avatar pjwj commented on August 10, 2024

This is how I use listChanges with sync state:

$api = API::withUsernameAndPassword($server, $user, $pass, $options);
$calendar = $api->getCalendar();

$changes = $calendar->listChanges();

$syncState = $changes->getSyncState();

//first call of listChanges() with syncState
$changesSinceLastCheck = $calendar->listChanges($syncState);
$syncState2 = $changesSinceLastCheck->getSyncState();

//second call of listChanges() with syncState
$changesSinceLastCheck2 = $calendar->listChanges($syncState2);

$createdElements = $changesSinceLastCheck->getChanges()->getCreate();
$createdElements2 = $changesSinceLastCheck->getChanges()->getCreate();


//dump subject texts for elements listed by first call
foreach ($createdElements as $element) {
    $elementWithBody = $calendar->getCalendarItem($element->getCalendarItem()->getItemId()->getId(), $element->getCalendarItem()->getItemId()->getChangeKey());
    var_dump($elementWithBody->getSubject());
}

//dump subject texts for elements listed by second call
foreach ($createdElements2 as $element) {
    $elementWithBody = $calendar->getCalendarItem($element->getCalendarItem()->getItemId()->getId(), $element->getCalendarItem()->getItemId()->getChangeKey());
    var_dump($elementWithBody->getSubject());
}

from php-ews.

Garethp avatar Garethp commented on August 10, 2024

Just to double check, is that what you've got in your source code? Because

$createdElements = $changesSinceLastCheck->getChanges()->getCreate();
$createdElements2 = $changesSinceLastCheck->getChanges()->getCreate();

are both reading from the same $changesSinceLastCheck, when $createdElements2 should be reading from $changesSinceLastCheck2 instead.

Also, a tip: If you already have the completed itemId (like from getItemId()), you can bypass the getCalendarItem() function for more readability. For example

$elementWithBody = $calendar->getItem($element->getCalendarItem()->getItemId());

Also, maybe it would be a good idea to dump the ItemId of the elements instead of the subject? That way you have a better way to see if they're the same item or just two items with the same subject?

from php-ews.

pjwj avatar pjwj commented on August 10, 2024

Thank you! It works now, changing the second $changesSinceLastCheck to $changesSinceLastCheck2, my dumb mistake.

from php-ews.

Garethp avatar Garethp commented on August 10, 2024

No problem :) I'm glad it worked for you. I don't use that function, so I didn't know if there was a bug or not. I realized that I didn't unit test fetching changes when you pass in an existing syncState, so I'm writing those tests now.

from php-ews.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.