Files
PocketSharp/PocketSharp.Website/index.html
T
2013-07-13 12:51:49 +02:00

289 lines
12 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>PocketSharp - a C#.NET class library that integrates the Pocket API</title>
<meta charset="utf-8" />
<meta name="robots" content="index,follow" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="PocketSharp is a C#.NET class library that integrates the Pocket API" />
<meta name="author" content="cee" />
<meta name="msvalidate.01" content="8E69C8BDF4C9B86924E9DA609952B416" />
<meta property="twitter:site" content="&#64;artistandsocial" />
<meta property="twitter:creator" content="&#64;artistandsocial" />
<meta property="og:title" content="PocketSharp - a C#.NET class library" />
<meta property="og:url" content="http://pocketsharp.frontendplay.com/" />
<meta property="og:site_name" content="PocketSharp" />
<meta property="og:description" content="PocketSharp is a C#.NET class library that integrates the Pocket API" />
<meta property="og:image" content="http://frontendplay.com/Content/Images/frontendplay-200.png" />
<link rel="shortcut icon" type="image/ico" href="/Content/Images/frontendplay.ico" />
<link rel="icon" type="image/png" href="/Content/Images/frontendplay.png" />
<link rel="image_src" href="/Content/Images/frontendplay-200.png" />
<link href="/Debug/app.css" rel="stylesheet" />
</head>
<body>
<div class="app">
<aside class="app-side">
<h1>
<a href="/"><i class="entypo-code"></i>PocketSharp</a>
</h1>
<p class="app-description">
PocketSharp is a C#.NET class library, that integrates the Pocket API v3
</p>
<div class="app-nuget">
<code>Install-Package PocketSharp</code>
</div>
<div class="app-social">
<a href="https://github.com/ceee/PocketSharp"><i class="entypo-github"></i></a>
<a href="https://twitter.com/artistandsocial"><i class="entypo-twitter"></i></a>
</div>
</aside>
<div class="app-main">
<nav class="app-nav">
<a href="#" data-id="gettingstarted" class="is-active">Getting Started</a>
<a href="#" data-id="authentication">Authentication</a>
<a href="#" data-id="retrieve">Retrieve</a>
<a href="#" data-id="add">Add</a>
<a href="#" data-id="modify">Modify</a>
</nav>
<article class="article">
<div data-part="gettingstarted">
<h2>Getting Started</h2>
<p>Request a <a href="http://getpocket.com/developer/apps/">Consumer Key on Pocket.</a></p>
<p>Include the PocketSharp namespace and it's associated models (you will need them later):</p>
<pre class="language-clike"><code>using PocketSharp;
using PocketSharp.Models;</code></pre>
<p>Initialize PocketClient with:</p>
<pre class="language-clike"><code>PocketClient _client = new PocketClient(&quot;[YOUR_CONSUMER_KEY]&quot;, &quot;[YOUR_ACCESS_CODE]&quot;);</code></pre>
<p>Do a simple request - e.g. a search for <code>CSS</code>:</p>
<pre class="language-clike"><code>_client.Search(&quot;css&quot;).ForEach(
item =&gt; Console.WriteLine(item.ID + &quot; | &quot; + item.Title)
);</code></pre>
<p>Which will output:</p>
<pre class="language-markup"><code>330361896 | CSS Front-end Frameworks with comparison : By usabli.ca
345541438 | Editr - HTML, CSS, JavaScript playground
251743431 | CSS Architecture
343693149 | CSS3 Transitions - Thank God We Have A Specification!
...</code></pre>
<h2>Create an instance</h2>
<p>Constructor:</p>
<pre class="language-clike"><code>PocketClient(string consumerKey, string accessCode = null, Uri callbackUri = null)</code></pre>
<p>
<code>consumerKey</code>: The API key
<br>
<code>accessCode</code>: Provide an access code if the user is already authenticated
<br>
<code>callbackUri</code>: The callback URL is called by Pocket after authentication
</p>
<p>Example:</p>
<pre class="language-clike"><code>PocketClient _client = new PocketClient(
consumerKey: &quot;123498237423498723498723&quot;,
callbackUri: new Uri(&quot;http:&frasl;&frasl;ceecore.com&quot;),
accessCode: &quot;097809-oi987-izi8-jk98-oiuu89&quot;
);</code></pre>
<p>You can change the <em>Access Code</em> after initialization:</p>
<pre class="language-clike"><code>_client.AccessCode = &quot;[YOU_ACCESS_CODE]&quot;;</code></pre>
<p>
<strong>Before authentication</strong> you will need to provide the <code>callbackUri</code> for authentication requests.
<br>
<strong>After authentication</strong> you will need to provide the <code>accessCode</code>.
</p>
<h2>Release History</h2>
<ul>
<li>2013-07-07 v0.3.1 authentication fixes</li>
<li>2013-07-02 v0.3.0 update authentication process </li>
<li>2013-06-27 v0.2.0 add, modify item &amp; modify tags</li>
<li>2013-06-26 v0.1.0 authentication &amp; retrieve functionality</li>
</ul>
<h2>Used Packages</h2>
<ul>
<li><a href="http://restsharp.org/">RestSharp</a></li>
<li><a href="https://github.com/ServiceStack/ServiceStack.Text">ServiceStack.Text</a></li>
</ul>
<h2>Contributors</h2>
<p>
<a href="https://github.com/ceee" title="Tobias Klika @ceee on github">
<img src="http://gravatar.com/avatar/9c61b1f4307425f12f05d3adb930ba66?s=40" alt="twitter/artistandsocial" /></a> &nbsp; <a href="https://github.com/ceee">Tobias Klika @ceee</a>
</p>
</div>
<div data-part="authentication">
<h2>Authentication</h2>
<p>In order to communicate with a Pocket User, you will need a consumer key (which is generated by <a href="http://getpocket.com/developer/apps/">creating a new application on Pocket</a>) and an <strong>Access Code</strong>.</p>
<p>The authentication is a 3-step process:</p>
<h4>1) Generate authentication URI</h4>
<p>Receive the <strong>request code</strong> and <strong>authentication URI</strong> from the library by calling <code>string GetRequestCode()</code>:</p>
<pre class="language-clike"><code>string requestCode = _client.GetRequestCode();
// 0f453f2d-1605-8584-28fd-39af8e
Uri authenticationUri = _client.GenerateAuthenticationUri();
// https://getpocket.com/auth/authorize?request_token=0f453f2d-1605-8584-28fd-39af8e&amp;redirect_uri=http%253a%252f%252fceecore.com</code></pre>
<p>The <em>request code</em> is stored internally, but you can also provide it as param in <code>GenerateAuthenticationUri(string requestCode = null)</code>.</p>
<h4>2) Redirect to Pocket</h4>
<p>Next you need to redirect the user to the <code>authenticationUri</code>, which displays a prompt to grant permissions for the application (see image). After the user granted or denied, he/she is redirected to the <code>callbackUri</code>.</p>
<p>
<img src="https://raw.github.com/ceee/PocketSharp/master/PocketSharp/authentication-screen.png" alt="authentication screen" /></p>
<h4>3) Get Access Code</h4>
<p>Call <code>string GetAccessCode(string requestCode = null)</code></p>
<pre class="language-clike"><code>string accessCode = _client.GetAccessCode();
// fa8bfc16-69b3-4d22-7db7-84a58d</code></pre>
<p>
Again, the received <em>access code</em> is stored internally.
Note that <code>GetAccessCode</code> can only be called with an existing <em>request code</em>. If you need to re-authenticate a user, start again with Step 1).
</p>
<h4>Important</h4>
<p>
<strong>Be sure to permanently store the <em>Access Code</em> for your user.</strong>
<br>
Without it you would always have to redo the authentication process.
</p>
</div>
<div data-part="retrieve">
<h2>Retrieve</h2>
<p>Get list of all items:</p>
<pre class="language-clike"><code>List&lt;PocketItem&gt; items = _client.Retrieve();
// equivalent to: _client.Retrieve(RetrieveFilter.All)</code></pre>
<p>Find items by a tag:</p>
<pre class="language-clike"><code>List&lt;PocketItem&gt; items = _client.SearchByTag(&quot;tutorial&quot;);</code></pre>
<p>Find items by a search string:</p>
<pre class="language-clike"><code>List&lt;PocketItem&gt; items = _client.Search(&quot;css&quot;);</code></pre>
<p>Find items by a filter:</p>
<pre class="language-clike"><code>List&lt;PocketItem&gt; items = _client.Retrieve(RetrieveFilter.Favorite); // only favorites</code></pre>
<p>The RetrieveFilter Enum is specified as follows:</p>
<pre class="language-clike"><code>enum RetrieveFilter { All, Unread, Archive, Favorite, Article, Video, Image }</code></pre>
<h4>Custom Parameters</h4>
<p>You can create a completely custom parameter list for retrieval with the POCO <code>RetrieveParameters</code>:</p>
<pre class="language-clike"><code>
var parameters = new RetrieveParameters()
{
Count = 50,
Offset = 100,
Sort = SortEnum.oldest
...
};
List&lt;pocketitem&gt; items = _client.Retrieve(parameters);
</code></pre>
</div>
<div data-part="add">
<h2>Add</h2>
<p>
Adds a new item to your pocket list.
Accepts four parameters, with <code>uri</code> being required.
</p>
<pre class="language-clike"><code>PocketItem Add(Uri uri, string[] tags = null, string title = null, string tweetID = null)</code></pre>
<p>Example:</p>
<pre class="language-clike"><code>PocketItem newItem = _client.Add(
new Uri(&quot;http:&frasl;&frasl;www.neowin.net/news/full-build-2013-conference-sessions-listing-revealed&quot;),
new string[] { &quot;microsoft&quot;, &quot;neowin&quot;, &quot;build&quot; }
);</code></pre>
<p>The title can be included for cases where an item does not have a title, which is typical for image or PDF URLs. If Pocket detects a title from the content of the page, this parameter will be ignored.</p>
<p>If you are adding Pocket support to a Twitter client, please send along a reference to the tweet status id (with the tweetID). This allows Pocket to show the original tweet alongside the article.</p>
</div>
<div data-part="modify">
<h2>Modify</h2>
<p>All Modify methods accept either the itemID (as int) or a <code>PocketItem</code> as parameter.</p>
<p>Archive the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.Archive(myPocketItem);
</code></pre>
<p>Un-archive the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.Unarchive(myPocketItem);
</code></pre>
<p>Favorites the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.Favorite(myPocketItem);
</code></pre>
<p>Un-favorites the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.Unfavorite(myPocketItem);
</code></pre>
<p>Deletes the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.Delete(myPocketItem);
</code></pre>
<h4>Modify tags</h4>
<p>Add tags to the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.AddTags(myPocketItem, new string[] { &quot;css&quot;, &quot;2013&quot; });
</code></pre>
<p>Remove tags from the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.RemoveTags(myPocketItem, new string[] { &quot;css&quot;, &quot;2013&quot; });
</code></pre>
<p>Remove all tags from the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.RemoveTags(myPocketItem);
</code></pre>
<p>Replaces all existing tags with new ones for the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.ReplaceTags(myPocketItem, new string[] { &quot;css&quot;, &quot;2013&quot; });
</code></pre>
<p>Renames a tag for the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.RenameTag(myPocketItem, &quot;oldTagName&quot;, &quot;newTagName&quot;);
</code></pre>
</div>
</article>
</div>
</div>
<script src="/Debug/app.js"></script>
</body>
</html>