Evernote/evernote-cloud-sdk-php

move note to different notebook

fnkr opened this issue · 13 comments

fnkr commented

How to move a note to a different notebook?

Use NoteStore.updateNote and set the notebookGuid field to the guid of the desired notebook. Documentation is here: https://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_updateNote

fnkr commented

I've already tried and it did not work for me.
Can you provide a php code sample, please?

Hi Florian,

I'll add a moveNote($note, $notebook) method today. It will handle business
notebooks, app notebooks, etc.

Thanks !

On Thu, Nov 6, 2014 at 10:19 AM, Florian Kaiser notifications@github.com
wrote:

I've already tried and it did not work for me.
Can you provide a php code sample, please?


Reply to this email directly or view it on GitHub
#4 (comment)
.

Laurent Sarrazin

fnkr commented

Latest commit is form Oct 27, 2014, sure github is up to date with your local copy?

Well actually the "real" latest commit is from yesterday on the "find_notes" branch ;)
But yes the latest commit on master is from Oct 27.
I'm working on the moveNote method right now.
One of the problem is that it's not possible to move a note from a personal notebook to a linked or business notebook through the api.
The solution would be to copy the note then delete the original one but it will stay in the trash... Not sure if it's a good idea.

What do you think of it ?

fnkr commented

That is what I do at the moment.

// $notebook: name of the notebook if note has to be moved to another notebook, or false
// $notebooks: array with notebook names as keys and guids as values
if($notebook) {
    $_notebook = new \Evernote\Model\Notebook();
    $_notebook->guid = $notebooks[$notebook];
    $client->uploadNote($note, $_notebook);
    $client->deleteNote($note);
} else {
    $client->replaceNote($note, $note);
}

But it is indeed a problem that the old notes are still in the trash bin.
Maybe its time to add a new API? What does the offical Evernote client do at this point?

Well actually that's what the desktop clients do : create a copy then delete the original...
The only difference is that the clients can use the expungeNote method that completely deletes the note.
So I guess I'll stick with the create/delete solution.

fnkr commented

If I move a note to another notebook, is my upload quota affected?

Not from the desktop clients. I need to make a few tests to be sure for the API.

So no it does not affect the upload quota.
You can run a composer update to get the moveNote method.
I've also added a move_note.php file in the sample/client directory
Please report any issue you might encounter. Thank you.

@Laurent-Sarrazin Hi, I find that when moving a note between two business notebook on Evernote client or Evernote Web, the note's guid stays the same. However using your moveNote needs to create a whole new note. Can you explain it?

Hi,
when you move a note, it actually creates a copy then deletes the original. That's why you get a different guid.
It's the behaviour of the desktop client too. The only difference is that the desktop client completely deletes the original note (and doesn't puts it in the trash) whereas the api puts the file in the trash as it cannot use the expungeNote() method.

@Laurent-Sarrazin I understand the copy-and-delete method. However, what I'm trying to say is that your official desktop and web clients seem not using this method because the guid doesn't change after moving between business account.

Only when I move a note from a business notebook to a personal notebook, it seems using your copy-and-delete way because it shows me a message like "Moving note requires some time blabla".

You can have a try in your Evernote clients. My question is how to move a note between business account without changing the guid? Is there any internal API?