アプリを介して「EverNote」にデータを保存したい(画像またはテキスト、またはその両方)。
私はググって、EverNote SDKのようなガイダンスを得て、EverNoteCounterサンプルも入手しました(これを実行すると、getCountボタンをクリックすると、「認証できませんでした」という警告メッセージが表示されます)。開発者トークンも生成しました。
しかし、consumerKey、consumerSecret を作成できません。また、アプリから evernote にデータを保存する方法も見つかりませんでした。
このようなリンクがいくつかありました
しかし、そのリンクをたどると、(この URL では HTTP メソッド GET はサポートされていません) と表示されます。
EVERNOTE で認証でき、そのアカウントのノートブックの数を取得できました。
アプリで sqllite を使用しています。画像用に 1 つのフォルダーを使用しています。Sqllite には画像リンク情報があります。
データの保存方法。
次のコードを使用して認証し、カウントを取得しました
- (IBAction)retrieveUserNameAndNoteCount:(id)sender
{
// Create local reference to shared session singleton
EvernoteSession *session = [EvernoteSession sharedSession];
[session authenticateWithViewController:self completionHandler:^(NSError *error) {
// Authentication response is handled in this block
if (error || !session.isAuthenticated) {
// Either we couldn't authenticate or something else went wrong - inform the user
if (error) {
NSLog(@"Error authenticating with Evernote service: %@", error);
}
if (!session.isAuthenticated) {
NSLog(@"User could not be authenticated.");
}
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Error"
message:@"Could not authenticate"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] autorelease];
[alert show];
} else {
// We're authenticated!
EvernoteUserStore *userStore = [EvernoteUserStore userStore];
// Retrieve the authenticated user as an EDAMUser instance
[userStore getUserWithSuccess:^(EDAMUser *user) {
// Set usernameField (UILabel) text value to username
[usernameField setText:[user username]];
// Retrieve total note count and display it
[self countAllNotesAndSetTextField];
} failure:^(NSError *error) {
NSLog(@"Error retrieving authenticated user: %@", error);
}];
}
}];
}
- (void)countAllNotesAndSetTextField
{
// Allow access to this variable within the block context below (using __block keyword)
__block int noteCount = 0;
EvernoteNoteStore *noteStore = [EvernoteNoteStore noteStore];
[noteStore listNotebooksWithSuccess:^(NSArray *notebooks) {
for (EDAMNotebook *notebook in notebooks) {
if ([notebook guid]) {
EDAMNoteFilter *filter = [[EDAMNoteFilter alloc] init];
[filter setNotebookGuid:[notebook guid]];
[noteStore findNoteCountsWithFilter:filter withTrash:NO success:^(EDAMNoteCollectionCounts *counts) {
if (counts) {
// Get note count for the current notebook and add it to the displayed total
NSNumber *notebookCount = (NSNumber *)[[counts notebookCounts] objectForKey:[notebook guid]];
noteCount = noteCount + [notebookCount intValue];
NSString *noteCountString = [NSString stringWithFormat:@"%d", noteCount];
[noteCountField setText:noteCountString];
}
} failure:^(NSError *error) {
NSLog(@"Error while retrieving note counts: %@", error);
}];
}
}
} failure:^(NSError *error) {
NSLog(@"Error while retrieving notebooks: %@", error);
}];
}
リンクを提案するか、ガイダンスを教えてください
事前にどうもありがとう