ruby on rails - Not able to create notebook and transfer files in evernote -
i developing web application , need create evernote notebook , transfer files in it.
i able authenticate user evernote not able create notebook. i'm confused how transfer files in notebook.
here authentication code. api url
for creating notebook:
notestore.createnotebook(access_token.token, "my_notebook") error:
an error occurred: undefined method `write' "my_notebook":string edit
following seth's lead
notebook = evernote::edam::type::notebook.new() notebook.name = "my_notebook3" x= notestore.createnotebook(access_token.token, notebook) note = evernote::edam::type::note.new() note.notebookguid = x.guid note.title="my note" y=notestore.createnote(access_token.token,note) working on file transfer in note.
the second parameter notebook structure, not string. need like:
notebook = evernote::edam::type::notebook.new() notebook.name = "my_notebook" notestore.createnotebook(access_token.token, notebook) evernote notebooks contain notes, , notes can have files attached them. attach file new note, need create resource , include in note:
filename = # file want attach image = file.open(filename, "rb") { |io| io.read } hashfunc = digest::md5.new hashhex = hashfunc.hexdigest(image) data = evernote::edam::type::data.new() data.size = image.size data.bodyhash = hashhex data.body = image resource = evernote::edam::type::resource.new() resource.mime = # appropriate mime type resource.data = data resource.attributes = evernote::edam::type::resourceattributes.new() resource.attributes.filename = filename note = evernote::edam::type::note.new() note.title = "title" note.content = '<?xml version="1.0" encoding="utf-8"?>' + '<!doctype en-note system "http://xml.evernote.com/pub/enml2.dtd">' + '<en-note>' + '<en-media type="' + resource.mime + '" hash="' + hashhex + '"/>' + '</en-note>' note.resources = [ resource ] creatednote = notestore.createnote(authtoken, note) the sample code in evernote api zip file demonstrates this. can download zip http://www.evernote.com/about/developer/api/.
Comments
Post a Comment