如何在Evernote Python API中获取共享笔记?

0 投票
1 回答
808 浏览
提问于 2025-04-17 22:18

我能从我的Evernote生产账户中获取自己的笔记。

但是,我无法获取另一个账户分享给我的笔记。

我不知道这是不是因为某些方法已经过时了,但我完全不明白这个问题。

如果有人能提供帮助、示例代码或者其他什么的,那就太好了!!

提前谢谢你们,

ehe

编辑:

我用来获取别人分享给我的笔记的代码如下:

def getEvernote():
    authToken= "my_auth_token"
    client = EvernoteClient(token=authToken, sandbox=False)
    userStore = client.get_user_store()
    user = userStore.getUser()
    noteStore = client.get_note_store()
    linked_notebooks = noteStore.listLinkedNotebooks(authToken)

    shared_note_store = client.get_shared_note_store(linked_notebooks[0])

    //Here, I manage to get the shared note store and the first shared notebook

    updated_filter = NoteFilter(words=' ')
    offset = 0
    max_notes = 40000
    result_spec = NotesMetadataResultSpec(includeTitle=True)

    //What is shareKey???????
    auth_result = shared_note_store.authenticateToSharedNotebook(shareKey, authToken)

    //EDAM error
    result_list = shared_note_store.findNotesMetadata(auth_result, updated_filter, offset, max_notes, result_spec)

有人能帮忙吗??

提前谢谢你们

ehe

1 个回答

2

你可以看看这里:http://dev.evernote.com/doc/articles/note-sharing.php(查看“列出账户中所有共享笔记”这一部分)。

你有没有一些代码可以展示一下?


这里有一些代码应该可以解决这个问题:

import evernote.edam.notestore.NoteStore as NoteStore

from evernote.api.client import EvernoteClient
from evernote.api.client import Store
from evernote.edam.notestore.ttypes import NoteFilter, NotesMetadataResultSpec

auth_token = "YOUR TOKEN"

client = EvernoteClient(token=auth_token, sandbox=True)

noteStore = client.get_note_store()

# get linked notebooks
linked_notebooks = noteStore.listLinkedNotebooks(auth_token)

linked_notebook = linked_notebooks[0]

# shareKey for the first notebook
shareKey = linked_notebook.shareKey

# get the right noteStore
note_store_uri = linked_notebook.noteStoreUrl
shared_note_store = Store(auth_token, NoteStore.Client, note_store_uri)


# authenticate to the linked notebook
auth_result = shared_note_store.authenticateToSharedNotebook(shareKey,auth_token)

# get the share token
share_token = auth_result.authenticationToken


updated_filter = NoteFilter(words=' ')
offset = 0
max_notes = 40000
result_spec = NotesMetadataResultSpec(includeTitle=True)

result_list = shared_note_store.findNotesMetadata(share_token, updated_filter, offset,             max_notes, result_spec)

print result_list

撰写回答