下面是一些代碼,應該工作。只要改變notebook.guid到你需要的筆記本的GUID:
//create filter for findNotesMetadata
filter = new Evernote.NoteFilter();
//set the notebook guid filter to the GUID of the default notebook
filter.notebookGuid = notebook.guid; //change this to the GUID of the notebook you want
//create a new result spec for findNotesMetadata
resultSpec = new Evernote.NotesMetadataResultSpec();
//set the result spec to include titles
resultSpec.includeTitle=true;
//call findNotesMetadata on the note store
noteStore.findNotesMetadata(filter, 0, 100, resultSpec, function(err, notesMeta) {
if (err) {
console.error('err',err);
}
else {
//log the number of notes found in the default notebook
console.log("Found "+notesMeta.notes.length+" notes in your default notebook . . .")
for (var i in notesMeta.notes) {
//list the title of each note in the default notebook
console.log(i+": "+notesMeta.notes[i].title);
}
}});
記住findNotesMetadata返回metadataList而不是票據的實際列表。如果您需要內容,則需要通過getNote下載每個音符,但在爲每個音符調用getNote之前,請檢查resultsSpec屬性中是否需要其他數據,因爲可能需要的許多數據可通過findNotesMetadata方法檢索。
這裏是一個完全正常工作(一旦你添加developer token),從默認的筆記本電腦檢索所有筆記和記錄筆記的標題代碼示例:
Evernote = require('evernote').Evernote;
var authToken = "your developer token";
if (authToken == "your developer token") {
console.log("Please fill in your developer token");
console.log("To get a developer token, visit https://sandbox.evernote.com/api/DeveloperToken.action");
process.exit(1);
}
var client = new Evernote.Client({token: authToken, sandbox: true});
var userStore = client.getUserStore();
var noteStore = client.getNoteStore();
var notebook=noteStore.getDefaultNotebook(function (err, notebook){
//create filter for findNotesMetadata
filter = new Evernote.NoteFilter();
//set the notebook guid filter to the GUID of the default notebook
filter.notebookGuid = notebook.guid;
//create a new result spec for findNotesMetadata
resultSpec = new Evernote.NotesMetadataResultSpec();
//set the result spec to include titles
resultSpec.includeTitle=true;
//call findNotesMetadata on the note store
noteStore.findNotesMetadata(filter, 0, 100, resultSpec, function(err, notesMeta) {
if (err) {
console.error('err',err);
}
else {
//log the number of notes found in the default notebook
console.log("Found "+notesMeta.notes.length+" notes in your default notebook . . .")
for (var i in notesMeta.notes) {
//list the title of each note in the default notebook
console.log(i+": "+notesMeta.notes[i].title);
}
}});
});
輸出樣本:
Found 3 notes in your default notebook . . .
0: This is a test note!
1: Hello Developer Forums!!!
2: How are you doin'?
你有沒有試過'noteStore.getNotebook(req.session.oauthAccessToken,[GUID]);'? – shennan
似乎很難找到官方可用的簡單樣本,用evernote API做基本的事情。我看到的樣本不完整,不要做這樣的事情。 – Cheeso