简单的 C# Evernote API OAuth 示例或指南?

发布于 2024-09-25 05:35:47 字数 238 浏览 2 评论 0原文

有人知道在哪里可以找到简单的 C# 代码示例吗?显然真的很难找到。

我刚刚开始,拿到了开发者密钥。

初始(确实是菜鸟问题/假设)--我的解决方案可以(应该/必须)是一个 Web 服务客户端吗?我不需要在 .Net 中安装新的库,对吗?

基本上,作为一个测试,我希望能够安全地以 html 形式呈现私人笔记本中的单个注释,类似于 HTML 中的 Everfort 导出在外部网站上的样子。

非常感谢!

Anybody know where I can find a simple example C# code example? Apparently really tough to find.

I'm just starting out, got my Developer key.

Initial (really noob question/presumption) - -Can (should/must) my solution be a web service client? No new libraries I need to install in .Net right?

Basically, as a test, I want to be able to securely present a single note from a private notebook in html similar to what the Everfort export in html looks like on a outside WebSite.

Many Thanks in Advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

调妓 2024-10-02 05:35:47

您应该首先从 http://www.evernote.com/about/developer 下载我们的 API ZIP /api/。您将在 /sample/csharp 中找到 C# 客户端示例代码。此示例代码演示了如何通过桌面应用程序使用 Evernote API,并使用用户名和密码进行身份验证。

You should start by downloading our API ZIP from http://www.evernote.com/about/developer/api/. You'll find C# client sample code in /sample/csharp. This sample code demonstrates using the Evernote API from a desktop application that authenticates using username and password.

浊酒尽余欢 2024-10-02 05:35:47

我不确定你是否成功了,但今天早上我正在尝试使用 Evernote、OpenAuth 和 C#,并设法让它全部正常工作。我整理了一篇博客文章/库,解释了这种体验并概述了如何使用 MVC 来实现它 - http://www.shaunmccarthy.com/evernote-oauth-csharp/ - 它使用 AsyncOAuth 库: https://github.com/neuecc/AsyncOAuth

我编写了一个围绕 AsyncOAuth 的包装器,您可能会在这里发现有用:https://github.com/shaunmccarthy/AsyncOAuth.Evernote.Simple

需要注意的一件棘手的事情 - Evernote 端点(/oauth 和 /OAuth.action)区分大小写

// Download the library from https://github.com/shaunmccarthy/AsyncOAuth.Evernote.Simple

// Configure the Authorizer with the URL of the Evernote service,
// your key, and your secret. 
var EvernoteAuthorizer = new EvernoteAuthorizer(
    "https://sandbox.evernote.com", 
    "slyrp-1234", // Not my real id / secret :)
    "7acafe123456badb123");

// First of all, get a request token from Evernote - this causes a 
// webrequest from your server to Evernote.
// The callBackUrl is the URL you want the user to return to once
// they validate the app
var requestToken = EvernoteAuthorizer.GetRequestToken(callBackUrl);

// Persist this token, as we are going to redirect the user to 
// Evernote to Authorize this app
Session["RequestToken"] = requestToken;

// Generate the Evernote URL that we will redirect the user to in
// order to 
var callForwardUrl = EvernoteAuthorizer.BuildAuthorizeUrl(requestToken);

// Redirect the user (e.g. MVC)
return Redirect(callForwardUrl);

// ... Once the user authroizes the app, they get redirected to callBackUrl

// where we parse the request parameter oauth_validator and finally get
// our credentials
// null = they didn't authorize us
var credentials = EvernoteAuthorizer.ParseAccessToken(
    Request.QueryString["oauth_verifier"], 
    Session["RequestToken"] as RequestToken);

// Example of how to use the credential with Evernote SDK
var noteStoreUrl = EvernoteCredentials.NotebookUrl;
var noteStoreTransport = new THttpClient(new Uri(noteStoreUrl));
var noteStoreProtocol = new TBinaryProtocol(noteStoreTransport);
var noteStore = new NoteStore.Client(noteStoreProtocol);
List<Notebook> notebooks = client.listNotebooks(EvernoteCredentials.AuthToken);

I am not sure if you ever got this working, but I was playing around with Evernote, OpenAuth and C# this morning and managed to get it all working. I have put together a blog post / library explaining the experience and outlining how to do it with MVC here - http://www.shaunmccarthy.com/evernote-oauth-csharp/ - it uses the AsyncOAuth library: https://github.com/neuecc/AsyncOAuth

I wrote a wrapper around AsyncOAuth that you might find useful here: https://github.com/shaunmccarthy/AsyncOAuth.Evernote.Simple

One prickly thing to be aware of - the Evernote Endpoints (/oauth and /OAuth.action) are case sensitive

// Download the library from https://github.com/shaunmccarthy/AsyncOAuth.Evernote.Simple

// Configure the Authorizer with the URL of the Evernote service,
// your key, and your secret. 
var EvernoteAuthorizer = new EvernoteAuthorizer(
    "https://sandbox.evernote.com", 
    "slyrp-1234", // Not my real id / secret :)
    "7acafe123456badb123");

// First of all, get a request token from Evernote - this causes a 
// webrequest from your server to Evernote.
// The callBackUrl is the URL you want the user to return to once
// they validate the app
var requestToken = EvernoteAuthorizer.GetRequestToken(callBackUrl);

// Persist this token, as we are going to redirect the user to 
// Evernote to Authorize this app
Session["RequestToken"] = requestToken;

// Generate the Evernote URL that we will redirect the user to in
// order to 
var callForwardUrl = EvernoteAuthorizer.BuildAuthorizeUrl(requestToken);

// Redirect the user (e.g. MVC)
return Redirect(callForwardUrl);

// ... Once the user authroizes the app, they get redirected to callBackUrl

// where we parse the request parameter oauth_validator and finally get
// our credentials
// null = they didn't authorize us
var credentials = EvernoteAuthorizer.ParseAccessToken(
    Request.QueryString["oauth_verifier"], 
    Session["RequestToken"] as RequestToken);

// Example of how to use the credential with Evernote SDK
var noteStoreUrl = EvernoteCredentials.NotebookUrl;
var noteStoreTransport = new THttpClient(new Uri(noteStoreUrl));
var noteStoreProtocol = new TBinaryProtocol(noteStoreTransport);
var noteStore = new NoteStore.Client(noteStoreProtocol);
List<Notebook> notebooks = client.listNotebooks(EvernoteCredentials.AuthToken);
又怨 2024-10-02 05:35:47

http://weblogs.asp .net/psteele/archive/2010/08/06/edamlibrary-evernote-library-for-c.aspx 可能会有所帮助。正如作者所说,它只是捆绑了一些并修复了一些。我自己没有尝试过,但我想我会提到一种可能更简单的入门方法。可能吧。

http://weblogs.asp.net/psteele/archive/2010/08/06/edamlibrary-evernote-library-for-c.aspx might help. As the author states it just bundles some and fixes some. Haven't tried it myself but thought I'd mention for a possibly easier way to get started. Possibly.

记忆で 2024-10-02 05:35:47

这也可能有帮助...发现它使用 Way Back Machine,因为原始博客网站已离线。

https://www.evernote.com/pub/bluecockatoo/Evernote_API#b=bb2451c9-b5ff-49bb-9686-2144d984c6ba&n=c30bc4eb-cca4-4a36-ad44-1e255eeb26dd

原始博文:< a href="http://web.archive.org/web/20090203134615/http://macrolinz.com/macrolinz/index.php/2008/12/" rel="nofollow">http://web.archive .org/web/20090203134615/http://macrolinz.com/macrolinz/index.php/2008/12/

向下滚动并找到 12 月 26 日的帖子 - “趁热吃……”

This might help too...found it using the Way Back Machine since the original blog site was offline.

https://www.evernote.com/pub/bluecockatoo/Evernote_API#b=bb2451c9-b5ff-49bb-9686-2144d984c6ba&n=c30bc4eb-cca4-4a36-ad44-1e255eeb26dd

The original blog post: http://web.archive.org/web/20090203134615/http://macrolinz.com/macrolinz/index.php/2008/12/

Scroll down and find the post from December 26 - "Get it while it's hot..."

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文