This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) makeNoteWithTitle:(NSString*)noteTile withBody:(NSString*) noteBody withParentNotebook:(EDAMNotebook*)parentNotebook { | |
NSString *noteContent = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | |
"<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">" | |
"<en-note>" | |
"%@" | |
"</en-note>",noteBody]; | |
// Parent notebook is optional; if omitted, default notebook is used | |
NSString* parentNotebookGUID; | |
if(parentNotebook) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ error | |
<html> | |
<head> | |
<title>Evernote Ruby Example App — Error</title> | |
</head> | |
<body> | |
<p>An error occurred: <%= @last_error %></p> | |
<p>Please <a href="/reset">start over</a>.</p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ index | |
<html> | |
<head> | |
<title>Evernote Ruby Example App</title> | |
</head> | |
<body> | |
<a href="/requesttoken">Click here</a> to authenticate this application using OAuth. | |
<% if session[:notebooks] %> | |
<hr /> | |
<h3>The current user is <%= session[:username] %> and there are <%= session[:total_notes] %> notes in their account</h3> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/callback' do | |
unless params['oauth_verifier'] || session['request_token'] | |
@last_error = "Content owner did not authorize the temporary credentials" | |
halt erb :error | |
end | |
session[:oauth_verifier] = params['oauth_verifier'] | |
begin | |
session[:access_token] = session[:request_token].get_access_token(:oauth_verifier => session[:oauth_verifier]) | |
redirect '/list' | |
rescue => e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/authorize' do | |
if session[:request_token] | |
redirect session[:request_token].authorize_url | |
else | |
# You shouldn't be invoking this if you don't have a request token | |
@last_error = "Request token not set." | |
erb :error | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/requesttoken' do | |
callback_url = request.url.chomp("requesttoken").concat("callback") | |
begin | |
session[:request_token] = client.authentication_request_token(:oauth_callback => callback_url) | |
redirect '/authorize' | |
rescue => e | |
@last_error = "Error obtaining temporary credentials: #{e.message}" | |
erb :error | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/list' do | |
begin | |
# Get notebooks | |
session[:notebooks] = notebooks.map(&:name) | |
# Get username | |
session[:username] = en_user.username | |
# Get total note count | |
session[:total_notes] = total_note_count | |
erb :index | |
rescue => e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/reset' do | |
session.clear | |
redirect '/' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/' do | |
erb :index | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def total_note_count | |
filter = Evernote::EDAM::NoteStore::NoteFilter.new | |
counts = note_store.findNoteCounts(auth_token, filter, false) | |
notebooks.inject(0) do |total_count, notebook| | |
total_count + (counts.notebookCounts[notebook.guid] || 0) | |
end | |
end |