使用印象笔记 API 创建笔记
Posted
技术标签:
【中文标题】使用印象笔记 API 创建笔记【英文标题】:createNote using Evernote API 【发布时间】:2012-10-26 18:36:17 【问题描述】:EvernoteNoteStore *noteStore = [EvernoteNoteStore noteStore];
EDAMNote *note = [[EDAMNote alloc] init];
[note setTitle:@"Test Note from EvernoteCounter for iPhone"];
[note setContent:[ [NSString alloc] initWithFormat:@"<en-note>%@</en-note>",@"tete"];
[noteStore createNote:(note) success:^(EDAMNote *note)
NSLog(@"Received note guid: %@", [note guid]);
failure:^(NSError *error)
NSLog(@"Create note failed: %@", error);
];
我使用此代码通过evernote 激活createNote。但是 createNote 不返回任何值 - 它被困在称为 async 的内部 api 函数之一中。有没有人尝试使用 ios 的 SDK 上的 API 创建新笔记,并且实际上在他们的 Evernote 帐户中获得了笔记?
【问题讨论】:
【参考方案1】:我们刚刚添加了一些新的示例代码来创建照片笔记。请查看:https://github.com/evernote/evernote-sdk-ios。创建笔记的正确方法是使用:
- (id) initWithGuid: (EDAMGuid) guid title: (NSString *) title content: (NSString *) content contentHash: (NSData *) contentHash contentLength: (int32_t) contentLength created: (EDAMTimestamp) created updated: (EDAMTimestamp) updated deleted: (EDAMTimestamp) deleted active: (BOOL) active updateSequenceNum: (int32_t) updateSequenceNum notebookGuid: (NSString *) notebookGuid tagGuids: (NSArray *) tagGuids resources: (NSArray *) resources attributes: (EDAMNoteAttributes *) attributes tagNames: (NSArray *) tagNames;
另请参阅:http://dev.evernote.com/documentation/reference/Types.html#Struct_Note 了解更多信息。
【讨论】:
【参考方案2】:Sample code for u. @KatieK
// --------------------------------
EvernoteNoteStore *noteStore = [EvernoteNoteStore noteStore];
EDAMNote *note = [[EDAMNote alloc] init];
[note setTitle:@"Hello Evernote"];
[note setContent:[[NSString alloc] initWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\"><en-note>Hello, world! %@</en-note>",@"I'm LongPham"]];
[noteStore createNote:note success:^(EDAMNote *note)
NSLog(@"Received note guid: %@", [note guid]);
failure:^(NSError *error)
NSLog(@"Create note failed: %@", error);
];
【讨论】:
以上是关于使用印象笔记 API 创建笔记的主要内容,如果未能解决你的问题,请参考以下文章