Search code examples
phpevernote

Adding a tag to existing Note?


I'm trying to update a note(s) that are returned from an Evernote search using PHP. The search part works just fine, but once I find the list of notes I can't seem to add a tag to the note. I can confirm that tag GUIDs are correct in both cases.

    use EDAM\NoteStore\NoteFilter;
$client = new Client(array(
 'token' => $authToken,
 'sandbox' => true
));
$filter = new NoteFilter();

$filter->words = "HIGH";
$filter->tagGuids =  array("ababe33d-75e6-4a50-b2ba-61889bb2b8a6");
$notes_result = $client->getNoteStore()->findNotes($filter, 0, 10);
$notes = $notes_result->notes;
foreach ($notes as $note) {
    echo $note->title . "\n";
    // **** ERROR HERE ****
    $note->updateTag($authToken, "b3b290fa-4ca0-493e-8dd1-5cf1bff28b92");
}

Solution

  • The error you get is because updateTag must be called on NoteStore, not the note object. But: NoteStore.updateTag updates the tag object itself. To add tag to a note one needs NoteStore.updateNote instead. Your API token must also support write permission on notes.