2

アプリを介して「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);
    }];
}

リンクを提案するか、ガイダンスを教えてください

事前にどうもありがとう

4

2 に答える 2

2

開発者トークンは、自分のアカウントにのみアクセスする必要がある場合に使用します。コンシューマ キー/シークレットを取得するには、http: //dev.evernote.com/documentation/cloud/にアクセスしてください。

iOS を使用している場合は、https://github.com/evernote/evernote-sdk-iosにサンプル アプリがあり、コンシューマー キーとシークレットを取得すると使用できます。

一般に、dev.evernote.com には多くの情報があります。

すべての SDK はhttps://github.com/evernoteにあります。

iOS の入門ガイド: http://blog.evernote.com/tech/2012/05/24/evernote-sdk-integration-ios/

于 2012-12-27T18:25:43.097 に答える