2012-12-27 91 views
2

我想通過我們的應用程序(圖像或文本或兩者)在「EverNote」中存儲一些數據。我想通過我們的應用程序在「EverNote」中存儲一些數據

我google了一下,我得到了一些像EverNote SDK的指導,我也得到了EverNoteCounter示例(當我運行這個,當我點擊getCount按鈕它顯示一條警告消息「無法驗證」)。 我也生成了開發者令牌。

但我無法創建consumerKey,consumerSecret。而且我也沒有找到如何從我們的應用程序存儲我們的數據到Evernote。

我喜歡this一個

一些鏈接,但是當我去通過鏈接它說(HTTP GET方法不受此URL支持)

我能與Evernote的身份驗證,我能獲取該賬戶中的筆記本數量。

我在我的應用程序中使用了sqllite。我爲圖像使用一個文件夾。 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); 
    }]; 
} 

請給我建議的鏈接或者給我指導

感謝很多提前

回答

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/

+0

是的..我遵循這些鏈接,我也得到了EverNoteTest示例..還有一個錯誤說「EDAMUserException:未知」身份驗證失敗。我還給出了消費者密鑰和密鑰@ Mustafa – Babul

+0

您使用的是什麼主機名?您應該使用sandbox.evernote.com進行開發。如果您仍然看到問題,我會建議您在此處發佈您的問題:http://discussion.evernote.com/forum/61-evernote-for-developers/ – Mustafa

+0

我正在使用沙盒帳戶。現在我在formus上發佈了這個問題。感謝您的回答@Mustafa – Babul

0

你有沒有解決呢?如果不是這樣,我做了以下得到它的工作:

  1. 下載,包括SDK
  2. 得到consumerKey和祕密(如果你想訪問Notes太,然後 而不是基本的,你應該獲取完整的訪問, http://dev.evernote.com/documentation/cloud/右上角)
  3. 添加在info.plist中的URLType條目(「修改您的應用程序的主 plist文件」一章https://github.com/evernote/evernote-sdk-ios
  4. 副本中的會話初始化代碼(充滿使用者密鑰和機密,主機名應留有不變)並實施兩個應用程序委託特定代碼
  5. 應該在驗證用戶身份時傳遞(屏幕上)視圖控制器到authenticateWithViewController方法f.e.在AppDelegate中的RootViewController的

研究這個頁面,瞭解來自Evernote使用的模型層次:

http://dev.evernote.com/documentation/cloud/chapters/data_structure.php http://dev.evernote.com/documentation/reference/Types.html

圖像可以在現場data和文本被存儲爲EDAMResource(資源)爲EDAMNote(注)在字段content。兩者都由Evernote SDK的EvernoteNoteStore對象處理。

相關問題