Python Evernote SDK
项目描述
Python Evernote SDK
============================================
Evernote API版本1.25
此SDK旨在与Python 2.X一起使用
有关Evernote的beta Python 3 SDK,请参阅https://github.com/evernote/evernote-sdk-python3
概述
--------
本SDK包含用于从Python调用Evernote云API的包装代码。
SDK还包含一个示例脚本。该代码演示了SDK在单用户脚本中的基本使用。真实Web应用程序必须使用OAuth对Evernote服务进行身份验证。
先决条件
-------------
要使用SDK中的代码,您需要从http://dev.evernote.com/documentation/cloud获取API密钥。您还可以在该页面上找到完整的API文档。
要运行示例代码,您需要在您进行开发的地方的沙箱服务中有一个用户账户。在https://sandbox.evernote.com/Registration.action注册账户。
要运行客户端示例代码,您需要一个开发者令牌。您可以在https://sandbox.evernote.com/api/DeveloperToken.action获取一个。
入门 - 客户端
------------------------
位于`sample/client/EDAMTest.py`中的代码演示了使用Evernote API的基本方法,使用开发者令牌简化您在学习过程中的身份验证过程。
1. 打开`sample/client/EDAMTest.py`
2. 滚动到页面底部并填写您的Evernote开发者令牌。
3. 在命令行中,运行以下命令以执行脚本
```bash
$ export PYTHONPATH=../../lib; python EDAMTest.py
```
入门 - Django与OAuth
------------------------------------
Web应用程序必须使用OAuth对Evernote服务进行身份验证。位于sample/django中的代码包含一个简单的Web应用程序,演示了OAuth身份验证过程。该应用程序使用Django框架。您不需要为您的应用程序使用Django,但您需要它来运行示例代码。
1. 安装`django`、`oauth2`和`evernote`库。您也可以使用`requirements.txt`进行`pip`安装。
2. 打开文件`oauth/views.py`
3. 填写您的Evernote API消费者密钥和密钥。
4. 在命令行中,运行以下命令以启动示例应用程序
```bash
$ python manage.py runserver
```
5. 在浏览器中打开示例应用程序:`http://localhost:8000`
入门 - Pyramid与OAuth
-------------------------------------
如果您想使用Pyramid与Evernote API,sample/pyramid中的代码是一个好的起点。
1. 使用命令行中的pip安装示例项目,如下所示。
```bash
$ pip install -e .
```
2. 打开文件`development.ini`
3. 填写您的Evernote API消费者密钥和密钥。
4. 在命令行中,运行以下命令以启动示例应用程序
```bash
$ pserve development.ini
```
5. 在浏览器中打开示例应用程序:`http://localhost:6543`
使用方法
-----
### OAuth ###
```python
client = EvernoteClient(
consumer_key='YOUR CONSUMER KEY',
consumer_secret='YOUR CONSUMER SECRET',
sandbox=True # 默认:True
)
request_token = client.get_request_token('YOUR CALLBACK URL')
client.get_authorize_url(request_token)
=> https://sandbox.evernote.com/OAuth.action?oauth_token=OAUTH_TOKEN
```
获取访问令牌
```python
access_token = client.get_access_token(
request_token['oauth_token'],
request_token['oauth_token_secret'],
request.GET.get('oauth_verifier', '')
)
```
现在您可以调用其他API
```python
client = EvernoteClient(token=access_token)
note_store = client.get_note_store()
notebooks = note_store.listNotebooks()
```
### UserStore ###
获取令牌后,您可以使用UserStore。例如,如果您想调用UserStore.getUser
```python
client = EvernoteClient(token=access_token)
user_store = client.get_user_store()
user_store.getUser()
```
您可以在UserStore函数的参数中省略authenticationToken。
### NoteStore ###
如果您想调用NoteStore.listNotebooks
```python
note_store = client.get_note_store()
note_store.listNotebooks()
```
### NoteStore用于关联笔记本###
如果您想获取关联笔记本的标签
```python
linked_notebook = note_store.listLinkedNotebooks()[0]
shared_note_store = client.getSharedNoteStore(linked_notebook)
shared_notebook = shared_note_store.getSharedNotebookByAuth()
shared_note_store.listTagsByNotebook(shared_notebook.notebookGuid)
```
### NoteStore用于商业###
如果您想获取商业账户中的笔记本列表
```python
business_note_store = client.get_business_note_store()
business_note_store.listNotebooks()
```
### 参考资料###
- Evernote开发者:http://dev.evernote.com/
- API 文档: http://dev.evernote.com/documentation/reference/
已知问题
------------
### 正则表达式 ###
通常情况下,["re" 正则表达式模块](https://docs.pythonlang.cn/2/library/re.html)无法处理我们[限制](https://github.com/evernote/evernote-sdk-python/blob/master/lib/evernote/edam/limits/constants.py)中的某些正则表达式,但[re2](https://pypi.python.org/pypi/re2/)可以。
============================================
Evernote API版本1.25
此SDK旨在与Python 2.X一起使用
有关Evernote的beta Python 3 SDK,请参阅https://github.com/evernote/evernote-sdk-python3
概述
--------
本SDK包含用于从Python调用Evernote云API的包装代码。
SDK还包含一个示例脚本。该代码演示了SDK在单用户脚本中的基本使用。真实Web应用程序必须使用OAuth对Evernote服务进行身份验证。
先决条件
-------------
要使用SDK中的代码,您需要从http://dev.evernote.com/documentation/cloud获取API密钥。您还可以在该页面上找到完整的API文档。
要运行示例代码,您需要在您进行开发的地方的沙箱服务中有一个用户账户。在https://sandbox.evernote.com/Registration.action注册账户。
要运行客户端示例代码,您需要一个开发者令牌。您可以在https://sandbox.evernote.com/api/DeveloperToken.action获取一个。
入门 - 客户端
------------------------
位于`sample/client/EDAMTest.py`中的代码演示了使用Evernote API的基本方法,使用开发者令牌简化您在学习过程中的身份验证过程。
1. 打开`sample/client/EDAMTest.py`
2. 滚动到页面底部并填写您的Evernote开发者令牌。
3. 在命令行中,运行以下命令以执行脚本
```bash
$ export PYTHONPATH=../../lib; python EDAMTest.py
```
入门 - Django与OAuth
------------------------------------
Web应用程序必须使用OAuth对Evernote服务进行身份验证。位于sample/django中的代码包含一个简单的Web应用程序,演示了OAuth身份验证过程。该应用程序使用Django框架。您不需要为您的应用程序使用Django,但您需要它来运行示例代码。
1. 安装`django`、`oauth2`和`evernote`库。您也可以使用`requirements.txt`进行`pip`安装。
2. 打开文件`oauth/views.py`
3. 填写您的Evernote API消费者密钥和密钥。
4. 在命令行中,运行以下命令以启动示例应用程序
```bash
$ python manage.py runserver
```
5. 在浏览器中打开示例应用程序:`http://localhost:8000`
入门 - Pyramid与OAuth
-------------------------------------
如果您想使用Pyramid与Evernote API,sample/pyramid中的代码是一个好的起点。
1. 使用命令行中的pip安装示例项目,如下所示。
```bash
$ pip install -e .
```
2. 打开文件`development.ini`
3. 填写您的Evernote API消费者密钥和密钥。
4. 在命令行中,运行以下命令以启动示例应用程序
```bash
$ pserve development.ini
```
5. 在浏览器中打开示例应用程序:`http://localhost:6543`
使用方法
-----
### OAuth ###
```python
client = EvernoteClient(
consumer_key='YOUR CONSUMER KEY',
consumer_secret='YOUR CONSUMER SECRET',
sandbox=True # 默认:True
)
request_token = client.get_request_token('YOUR CALLBACK URL')
client.get_authorize_url(request_token)
=> https://sandbox.evernote.com/OAuth.action?oauth_token=OAUTH_TOKEN
```
获取访问令牌
```python
access_token = client.get_access_token(
request_token['oauth_token'],
request_token['oauth_token_secret'],
request.GET.get('oauth_verifier', '')
)
```
现在您可以调用其他API
```python
client = EvernoteClient(token=access_token)
note_store = client.get_note_store()
notebooks = note_store.listNotebooks()
```
### UserStore ###
获取令牌后,您可以使用UserStore。例如,如果您想调用UserStore.getUser
```python
client = EvernoteClient(token=access_token)
user_store = client.get_user_store()
user_store.getUser()
```
您可以在UserStore函数的参数中省略authenticationToken。
### NoteStore ###
如果您想调用NoteStore.listNotebooks
```python
note_store = client.get_note_store()
note_store.listNotebooks()
```
### NoteStore用于关联笔记本###
如果您想获取关联笔记本的标签
```python
linked_notebook = note_store.listLinkedNotebooks()[0]
shared_note_store = client.getSharedNoteStore(linked_notebook)
shared_notebook = shared_note_store.getSharedNotebookByAuth()
shared_note_store.listTagsByNotebook(shared_notebook.notebookGuid)
```
### NoteStore用于商业###
如果您想获取商业账户中的笔记本列表
```python
business_note_store = client.get_business_note_store()
business_note_store.listNotebooks()
```
### 参考资料###
- Evernote开发者:http://dev.evernote.com/
- API 文档: http://dev.evernote.com/documentation/reference/
已知问题
------------
### 正则表达式 ###
通常情况下,["re" 正则表达式模块](https://docs.pythonlang.cn/2/library/re.html)无法处理我们[限制](https://github.com/evernote/evernote-sdk-python/blob/master/lib/evernote/edam/limits/constants.py)中的某些正则表达式,但[re2](https://pypi.python.org/pypi/re2/)可以。
项目详情
关闭
evernote-1.25.3.tar.gz 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 796847e0b7517e729041c5187fa1665c3f6fc0491cb4d71fb95a62c4f22e64eb |
|
MD5 | b85637da6c3cd74670e80c79eedf8f66 |
|
BLAKE2b-256 | f96b877f8edef8ef040d32eb38f3bf6322ba334de9d10614d8db9d869c162fc1 |