ios - How we can Import Images from Evernote in iPhone sdk -
i developing app drawing tool project , need import image evernote account app.
i using below code note list. not able decode "data.bodyhash" nsdata , image become nil. can see in below code.
evernotesession *session = [evernotesession sharedsession]; edamnotefilter* filter = [[edamnotefilter alloc] initwithorder:0 ascending:no words:nil notebookguid:nil tagguids:nil timezone:nil inactive:no emphasized:nil]; [[evernotenotestore notestore] findnoteswithfilter:filter offset:0 maxnotes:100 success:^(edamnotelist *list) { (edamnote *note in list.notes) { nslog(@"notes : %@",note.title); nsmutablearray *resources = note.resources; if (resources!=nil) { edamresource* resource = [resources objectatindex:0]; edamdata *data = resource.data; uiimage *image = [[uiimage alloc]initwithdata:data.bodyhash]; /// image nil } } }
thanks
yes, it's possible. there steps should take achieve desired result.
1) ensure evernote application has full access user's evernote account able read existing notes (you can set when requesting evernote api key on https://dev.evernote.com )
2) authenticate
[self.session authenticatewithviewcontroller:self preferregistration:no completion:^(nserror* authenticateerror) { ... }];
3) find notes
[self.session findnoteswithsearch:nil innotebook:nil orscope:ensessionsearchscopeall sortorder:ensessionsortordernormal maxresults:255 completion:^(nsarray* findnotesresults, nserror* findnoteserror) { ... }];
4) download each note
for (ensessionfindnotesresult* result in findnotesresults) { [self.session downloadnote:result.noteref progress:null completion:^(ennote* note, nserror* downloadnoteerror) { ... }]; }
5) images
for (enresource* resource in note.resources) { if ([resource.mimetype hasprefix:@"image"]) { uiimage* image = [[uiimage alloc] initwithdata:resource.data]; ... } }
you can check sample project here.
if set consumer key , secret, after authentication you'll see similar console output:
2014-08-19 22:54:18.782 evernotetest[71234:60b] finding notes.. 2014-08-19 22:54:20.356 evernotetest[71234:60b] processing find notes results.. 2014-08-19 22:54:21.294 evernotetest[71234:60b] getting images note 'just image' 2014-08-19 22:54:21.294 evernotetest[71234:60b] >> image size {600, 400} 2014-08-19 22:54:21.295 evernotetest[71234:60b] 2014-08-19 22:54:21.720 evernotetest[71234:60b] getting images note 'getting started' 2014-08-19 22:54:21.721 evernotetest[71234:60b] >> image size {27, 27} 2014-08-19 22:54:21.721 evernotetest[71234:60b] >> image size {215, 54} 2014-08-19 22:54:21.722 evernotetest[71234:60b] >> image size {300, 300} 2014-08-19 22:54:21.722 evernotetest[71234:60b] >> image size {27, 27} 2014-08-19 22:54:21.723 evernotetest[71234:60b] >> image size {27, 27} 2014-08-19 22:54:21.723 evernotetest[71234:60b] >> image size {27, 27} 2014-08-19 22:54:21.724 evernotetest[71234:60b] >> image size {27, 27} 2014-08-19 22:54:21.724 evernotetest[71234:60b] >> image size {27, 27} 2014-08-19 22:54:21.725 evernotetest[71234:60b] >> image size {27, 27} 2014-08-19 22:54:21.725 evernotetest[71234:60b] 2014-08-19 22:54:22.179 evernotetest[71234:60b] getting images note 'another image' 2014-08-19 22:54:22.180 evernotetest[71234:60b] >> image size {685, 514} 2014-08-19 22:54:22.180 evernotetest[71234:60b]
hope helps
Comments
Post a Comment