Skip to content

Instantly share code, notes, and snippets.

@takuya
Created February 15, 2014 16:47
Show Gist options
  • Save takuya/9021836 to your computer and use it in GitHub Desktop.
Save takuya/9021836 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#coding:utf-8
require "rubygems"
require 'evernote'
#先程取得したToken
auth_token = "S=s23:U=270295:E=xxxxxxxxxxxx:C=xxxxxxxxx:P=1cd:A=en-devtoken:V=2:H=xxxxxxxxxxx816XXXXXXXXXXXX"
#ノートのエンドポイントのURL
note_store_url = "https://www.evernote.com/shard/s23/notestore"
# 正しくは以下のような形式じゃないとダメらしいけど、決め打ちでOKだった。
# note_store_url = "http://sandbox.evernote.com/edam/note/#{user.shardId}"
note_store = Evernote::NoteStore.new(note_store_url)
notebooks = note_store.listNotebooks(auth_token)
default_notebook = notebooks[0]
#ノートを作る
note = Evernote::EDAM::Type::Note.new()
puts "ノートタイトル入れて下さい" if ARGV.size<1
exit(-1) if ARGV.size<1
#note.title = ARGV.shift || "no title "
note.title = ARGV.join || "no title " # 空白を含んでも取ってしまえ
content = <<EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
<en-note>
<div><font face="'Hiragino Maru Gothic Pro'" color="#000C76" size="4">■①これは何? </font><font size="2">できたらどうなるの?</font>
</div>
<div>
<hr/>
</div>
<div><span style="font-size: 18px;"><br/></span>
</div>
<div><br/>
</div>
<div>
<div><font size="4"><font face="'Hiragino Maru Gothic Pro'" color="#000C76" size="4"><br/>
■②次にやること</font></font>
</div>
<div>
<hr/>
</div>
</div>
<div><span style="border-collapse: separate; border-spacing: 0px;"><en-todo/></span>
</div>
<div><span style="border-collapse: separate; border-spacing: 0px;"><en-todo/><br/></span>
</div>
<div><span style="border-collapse: separate; border-spacing: 0px;"><en-todo/><br/></span>
</div>
<div><span style="border-collapse: separate; border-spacing: 0px;"><br/></span>
</div>
<div><br/>
</div>
<div><br/>
</div>
<div><font face="'Hiragino Maru Gothic Pro'" color="#000C76" size="4">■③内容 </font><font size="2">具体的に、いつどこで、なにをやるの</font><br/>
</div>
<div>
<hr/>
<font size="4"><br/></font>
</div>
<div><br/>
</div>
<div><br/>
</div>
<div><br/>
</div>
<div><br/>
</div>
<div><br/>
</div>
<div><span style="color: rgb(0, 12, 118); font-family: 'Hiragino Maru Gothic Pro'; font-size: large;"><br/></span>
</div>
<div><span style="color: rgb(0, 12, 118); font-family: 'Hiragino Maru Gothic Pro'; font-size: large;">■④参考資料</span><br/>
</div>
<div>
<div>
<hr/>
</div>
<div><br/>
</div>
</div>
<div><br/>
</div>
<div>
<div><font size="4"><font face="'Hiragino Maru Gothic Pro'" color="#000C76" size="4">■⑤気になった事・そのうちやること・反省点</font></font>
</div>
<div>
<hr/>
<font size="4"><font size="4"><br/></font></font>
</div>
</div>
<div><font size="4"><br/></font>
</div>
</en-note>
EOS
note.content = content
begin
createdNote = note_store.createNote(auth_token, note) #ノートを保存
rescue => e
puts e
puts "ENMLシンタックスエラー" if e.errorCode == Evernote::EDAM::Error::EDAMErrorCode::ENML_VALIDATION
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment