首先evernote官方是没有linux版客户端的,所以我使用的是nixnote2(一个开源的第三方客户端)。
代码地址:https://github.com/baumgarr/nixnote2
可惜的是这个第三方客户端默认只能登录evernote的国际版(和中国版数据不互通)。对此,在nixnote2的作者之一在github上提出了如下两个解决方式:
baumgarr commented on 19 Mar 2017
There are two options.
One is to open the account maintenance dialog under the File menu. Click the “Add” button to create a new account. This will give you the option for what server to sync with.
The other option is to edit the ~/.nixnote/accounts.conf and change the tag. This only works if you’ve never synchronized the current account with Evernote. If you’ve already done a sync you’ll probably encounter weird problems.
大意就是说要么申请个国际版账号,要么改一下 ~/.nixnote/accounts.conf这个配置文件。至于怎么改配置文件他没有说,那我们先看下配置文件是怎么样的。
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE NixNote-Accounts>
<user-accounts>
<account>
<name>Default Account</name>
<id>1</id>
</account>
</user-accounts>
很明显,直接看配置文件是看不出什么东西的,所以要去看下它的源码是怎么处理这个配置文件的。
经过一番代码阅读后,配置文件的处理代码在/settings/accountsmanager.cpp
中。
https://github.com/baumgarr/nixnote2/blob/master/settings/accountsmanager.cpp
//********************************************
//* Set the server for an acocunt
//********************************************
QString AccountsManager::getServer() {
QDomElement element = currentNode.toElement();
QDomNode tokenNode = element.firstChildElement("server");
QString server = tokenNode.toElement().text();
if (server == "")
server = "www.evernote.com";
return server;
}
从这段代码可以看到程序会读取配置文件的 <server></server>
标签(有兴趣的可以自己看下QDomElement类的实现)。当nixnote2的配置文件是没有设置server时(默认是没设置的),它把server
设置为www.evernote.com
。
接着我们可以去官网找到印象笔记(中国版)的第三方认证地址。
https://dev.yinxiang.com/doc/articles/authentication.php/#temporary_token_request
可以得到印象笔记(中国版)的第三方认证地址为app.yinxiang.com
结论
打开accounts.conf文件
vim ~/.nixnote/accounts.conf
把里面的内容改成如下
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE NixNote-Accounts>
<user-accounts>
<account>
<id>1</id>
<server>app.yinxiang.com</server>
<name>test</name>
</account>
</user-accounts>