使用Evernote的Javascript SDK发出listNotebooks请求时出错

时间:2015-06-30 05:10:42

标签: javascript cordova thrift evernote

我正在使用Ionic框架创建Cordova / Phonegap移动应用程序。我使用Evernote的Javascript SDK并成功完成了OAuth流程。

我被困在最后一步。我试图列出我的笔记本电脑并继续生成错误。到目前为止,一切似乎都很好:

noteStore.listNotebooks(authTokenEvernote, function (notebooks)

此时,我收到的错误是" {" position":0," totalSize":0}"。我已经浏览了整个论坛,无法弄清楚它的意义或解决方法。

这是我的代码。

// authTokenEvernote can now be used to send request to the Evernote Cloud API
console.log('got access token:', authTokenEvernote)
console.log('got notestore url:', noteStoreURL)

// Here, we connect to the Evernote Cloud API and get a list of all of the
// notebooks in the authenticated user's account:

var noteStoreTransport = new Thrift.BinaryHttpTransport("noteStoreURL");
var noteStoreProtocol = new Thrift.BinaryProtocol(noteStoreTransport);
var noteStore = new NoteStoreClient(noteStoreProtocol);

noteStore.listNotebooks(authTokenEvernote, function (notebooks) {
                console.log('success!! : ');
                console.log(notebooks);

}, function onerror(error) {
                console.log('error:')
                console.log(error);        
});        

};

1 个答案:

答案 0 :(得分:0)

listNotebooks方法(与大多数Evernote方法一样)首先返回一个err对象,然后返回包含笔记本的对象。

以下是如何调用listNotebooks方法的示例:

var notebooks = noteStore.listNotebooks(function(err, notebooks) {
  console.log("Found " + notebooks.length + " notebooks:");
  for (var i in notebooks) {
    console.log("  * " + notebooks[i].name);
  }
  console.log(notebooks)

});