我正在使用Evernote的PHP SDK,我需要检索标记笔记的列表。当我按关键字或笔记本 giud 过滤时,它可以工作,但是一旦我设置 tagGuids,我就会得到空列表。
下面是示例代码:
$noteFilter=new EDAM'NoteStore'NoteFilter();
#For the sake of this example, I'm just getting all existing tags
#and adding them to filter so it should:
$tags=$noteStore->listTags($token);
$noteFilter->tagGuids=Array();
foreach($tags as $tag){
$noteFilter->tagGuids[]=$tag->guid;
}
$notes=$noteStore->findNotes($token,$noteFilter,0,20);
我有带标签的笔记。但这就是我得到的结果,一个空列表:
EDAM'NoteStore'NoteList Object
(
[startIndex] => 0
[totalNotes] => 0
[notes] => Array
(
)
[stoppedWords] =>
[searchedWords] =>
[updateCount] => 139
)
实际上,你不能做这种搜索。将 tagGuids 属性与 - 假设 - 2 个标签一起使用将导致同时搜索包含这两个标签的笔记。这是"AND"搜索,而不是"OR"搜索。
一种选择是进行多次搜索,每次搜索都有一个标签并合并结果......不是最佳的,但恐怕这是您唯一的解决方案。
你可以在这里找到一些帮助:https://dev.evernote.com/doc/articles/search_grammar.php
顺便说一句,findNotes方法已被弃用。您应该使用 findNotesMetadata 方法:
$resultSpec = new 'EDAM'NoteStore'NotesMetadataResultSpec();
$resultSpec->includeTitle;
$resultSpec->includeTagGuids;
$notes=$noteStore->findNotesMetadata($authToken,$noteFilter,0,20, $resultSpec);