2012/09/10

perlからevernote apiを使う


https://github.com/evernote/evernote-sdk-perl
はとてもバギーなので、
https://github.com/nobuoka/evernote-sdk-perl/tree/sample_code
を使うべし。サンプルコードも入っているのでとてもありがたい。

listNotebooksやfindNotesはメタデータなどしか返ってこない。
ノートの中身を見るにはgetNoteを使う。
そのサンプルは以下。

    my $notebooks = $note_store->listNotebooks( $auth_token );
    for my $notebook ( @$notebooks ) {
      my $filter = new EDAMNoteStore::NoteFilter();
      $filter->{notebookGuid} = $notebook->guid;
      my $notelist=$note_store->findNotes( $auth_token,$filter,0,10 );
      for my $n (@{$notelist->{notes}} ) {
        print Dump( $n->notes);
        print "- - - - - - - - \n";
        my $guid=$n->{guid};
        for my $b ($note_store->getNote( $auth_token,$guid,1,1,1,1) ) {
          #print Dump( $b);
          print $b->content;
        }
      }
    }


$notelist->{notes}
では$n->{guid}ができずに困っていた。
んでフォーラムを見たら
@{$notelist->{notes}}
とすべきと書いてあり、これで解決。

このあたりが、型にゆるいperlの嫌なところだよなぁ。
書いた人は当たり前なんだけど、第三者はきつい。

0 件のコメント: