Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b19739fc9 | |||
| ff8bbf17d3 | |||
| da892067ad | |||
| 3992a988fc | |||
| 2a98cfb0e4 | |||
| 3057612872 | |||
| 56180b5829 | |||
| 2a08adef45 | |||
| abfb9f6d78 | |||
| a1f6637e9d | |||
| 8bce874504 | |||
| 50ee8905c5 | |||
| 4d2650072f | |||
| 65e31ac2e2 | |||
| 456c4f17f2 | |||
| ee1e32b9ab | |||
| 9d677eea5a | |||
| 64098518fa | |||
| cc6aab227d | |||
| 543b3e8191 | |||
| 2186561fd8 | |||
| 8650883975 | |||
| 6ede86c367 | |||
| d373bdd9bf | |||
| b4ae55d8ab | |||
| aae43cf00d | |||
| a0e8022f1d | |||
| 4119dec95d | |||
| cf2d929d3a | |||
| e772b8df9e | |||
| d9c4b4c51f |
+2
-8
@@ -1,21 +1,15 @@
|
|||||||
; This file is for unifying the coding style for different editors and IDEs
|
; This file is for unifying the coding style for different editors and IDEs
|
||||||
; editorconfig.org
|
; editorconfig.org
|
||||||
|
|
||||||
; defaults by Tobias Klika
|
|
||||||
; 2013
|
|
||||||
|
|
||||||
root = true
|
root = true
|
||||||
|
|
||||||
|
|
||||||
; default settings for all files
|
|
||||||
[*]
|
[*]
|
||||||
end_of_line = crlf ; this is git standard, so it won't convert it anymore
|
end_of_line = crlf
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
|
|
||||||
[*.md]
|
[*.md]
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
### 2.2.0 (2013-10-26)
|
||||||
|
|
||||||
|
- Made `GetAccessCode` obsolete
|
||||||
|
- Return username after authentication with `GetUser` (thanks to [ScottIsAFool](https://github.com/ScottIsAFool))
|
||||||
|
|
||||||
|
### 2.1.0 (2013-10-25)
|
||||||
|
|
||||||
|
- Rename `Statistics()` to `GetUserStatistics()`
|
||||||
|
- Made `CallbackUri` public (thanks to [ScottIsAFool](https://github.com/ScottIsAFool))
|
||||||
|
- Added Fody/PropertyChanged (thanks to [ScottIsAFool](https://github.com/ScottIsAFool))
|
||||||
|
- Method `GetUsageLimits()` to retrieve API usage limits
|
||||||
|
- Add PORTABLE constant to SgmlReader
|
||||||
|
|
||||||
|
### 2.0.1 (2013-10-19)
|
||||||
|
|
||||||
|
- Catch HttpRequestExceptions and provide as InnerException for PocketException
|
||||||
|
- Read Article from URI (method overload)
|
||||||
|
|
||||||
|
### 2.0.0 (2013-10-17)
|
||||||
|
|
||||||
|
- Add Reader API _(does not use the official Article View API, which is private. The PocketReader is based on a custom PCL port of NReadability and SgmlReader)_
|
||||||
|
|
||||||
|
### 1.5.1 (2013-09-30)
|
||||||
|
|
||||||
|
- `RetrieveFilter.All` didn't work
|
||||||
|
- improve search speed
|
||||||
|
|
||||||
|
### 1.5.0 (2013-09-28)
|
||||||
|
|
||||||
|
- add statistics API
|
||||||
|
- add registration API
|
||||||
|
|
||||||
|
### 1.4.0 (2013-09-21)
|
||||||
|
|
||||||
|
- rename `Retrieve` to `Get`
|
||||||
|
- update IntelliSense documentation
|
||||||
|
- add `GetTags` method
|
||||||
|
|
||||||
|
### 1.3.0 (2013-09-19)
|
||||||
|
|
||||||
|
- get Item by ID
|
||||||
|
- tag modification bugfixes
|
||||||
|
|
||||||
|
### 1.2.1 (2013-09-18)
|
||||||
|
|
||||||
|
- correct parameter conversion for DateTime and Boolean
|
||||||
|
|
||||||
|
### 1.2.0 (2013-09-17)
|
||||||
|
|
||||||
|
- simplified retrieve methods
|
||||||
|
|
||||||
|
### 1.1.0 (2013-09-17)
|
||||||
|
|
||||||
|
- fix modification requests
|
||||||
|
|
||||||
|
### 1.0.0 (2013-09-15)
|
||||||
|
|
||||||
|
- convert to PCL
|
||||||
|
- implement async
|
||||||
|
|
||||||
|
### 0.3.2 (2013-08-16)
|
||||||
|
|
||||||
|
- tag modification fixed
|
||||||
|
- full retrieval of items for Retrieve method
|
||||||
|
|
||||||
|
### 0.3.1 (2013-07-07)
|
||||||
|
|
||||||
|
- authentication fixes
|
||||||
|
|
||||||
|
### 0.3.0 (2013-07-02)
|
||||||
|
|
||||||
|
- update authentication process
|
||||||
|
|
||||||
|
### 0.2.0 (2013-06-27)
|
||||||
|
|
||||||
|
- add, modify item
|
||||||
|
- modify tags
|
||||||
|
|
||||||
|
### 0.1.0 (2013-06-26)
|
||||||
|
|
||||||
|
- authentication
|
||||||
|
- retrieve functionality
|
||||||
@@ -74,11 +74,17 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="mscorlib" />
|
<Reference Include="mscorlib" />
|
||||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
<Reference Include="System.Runtime">
|
<Reference Include="System.IO, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Microsoft.Bcl.1.0.19\lib\sl5\System.Runtime.dll</HintPath>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\packages\Microsoft.Bcl.1.1.3\lib\sl5\System.IO.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Threading.Tasks">
|
<Reference Include="System.Runtime, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Microsoft.Bcl.1.0.19\lib\sl5\System.Threading.Tasks.dll</HintPath>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\packages\Microsoft.Bcl.1.1.3\lib\sl5\System.Runtime.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Threading.Tasks, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\packages\Microsoft.Bcl.1.1.3\lib\sl5\System.Threading.Tasks.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Windows" />
|
<Reference Include="System.Windows" />
|
||||||
<Reference Include="system" />
|
<Reference Include="system" />
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Microsoft.Bcl" version="1.0.19" targetFramework="sl50" />
|
<package id="Microsoft.Bcl" version="1.1.3" targetFramework="sl50" />
|
||||||
<package id="Microsoft.Bcl.Async" version="1.0.16" targetFramework="sl50" />
|
<package id="Microsoft.Bcl.Async" version="1.0.16" targetFramework="sl50" />
|
||||||
<package id="Microsoft.Bcl.Build" version="1.0.10" targetFramework="sl50" />
|
<package id="Microsoft.Bcl.Build" version="1.0.10" targetFramework="sl50" />
|
||||||
</packages>
|
</packages>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
@@ -49,12 +49,13 @@
|
|||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Net" />
|
<Reference Include="System.Net" />
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Net.Http.Extensions">
|
<Reference Include="System.Net.Http.Extensions, Version=2.2.15.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.13\lib\net45\System.Net.Http.Extensions.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Net.Http.Primitives, Version=4.2.13.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.13\lib\net45\System.Net.Http.Primitives.dll</HintPath>
|
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.15\lib\net45\System.Net.Http.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Http.Primitives, Version=4.2.15.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.15\lib\net45\System.Net.Http.Primitives.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Net.Http.WebRequest" />
|
<Reference Include="System.Net.Http.WebRequest" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
@@ -140,4 +141,4 @@
|
|||||||
<Target Name="AfterBuild">
|
<Target Name="AfterBuild">
|
||||||
</Target>
|
</Target>
|
||||||
-->
|
-->
|
||||||
</Project>
|
</Project>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
<bindingRedirect oldVersion="0.0.0.0-4.2.13.0" newVersion="4.2.13.0" />
|
<bindingRedirect oldVersion="0.0.0.0-4.2.15.0" newVersion="4.2.15.0" />
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
</assemblyBinding>
|
</assemblyBinding>
|
||||||
</runtime>
|
</runtime>
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
<package id="Microsoft.Bcl" version="1.1.3" targetFramework="net45" />
|
<package id="Microsoft.Bcl" version="1.1.3" targetFramework="net45" />
|
||||||
<package id="Microsoft.Bcl.Async" version="1.0.16" targetFramework="net45" />
|
<package id="Microsoft.Bcl.Async" version="1.0.16" targetFramework="net45" />
|
||||||
<package id="Microsoft.Bcl.Build" version="1.0.10" targetFramework="net45" />
|
<package id="Microsoft.Bcl.Build" version="1.0.10" targetFramework="net45" />
|
||||||
<package id="Microsoft.Net.Http" version="2.2.13" targetFramework="net45" />
|
<package id="Microsoft.Net.Http" version="2.2.15" targetFramework="net45" />
|
||||||
</packages>
|
</packages>
|
||||||
@@ -151,5 +151,14 @@ namespace PocketSharp.Tests
|
|||||||
|
|
||||||
Assert.True(statistics.CountAll > 0);
|
Assert.True(statistics.CountAll > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task AreLimitsRetrieved()
|
||||||
|
{
|
||||||
|
PocketLimits limits = await client.GetUsageLimits();
|
||||||
|
|
||||||
|
Assert.True(limits.RateLimitForConsumerKey > 9999);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,11 +46,13 @@
|
|||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Net" />
|
<Reference Include="System.Net" />
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Net.Http.Extensions">
|
<Reference Include="System.Net.Http.Extensions, Version=2.2.15.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Microsoft.Net.Http.2.2.13\lib\net45\System.Net.Http.Extensions.dll</HintPath>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\packages\Microsoft.Net.Http.2.2.15\lib\net45\System.Net.Http.Extensions.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Net.Http.Primitives">
|
<Reference Include="System.Net.Http.Primitives, Version=4.2.15.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Microsoft.Net.Http.2.2.13\lib\net45\System.Net.Http.Primitives.dll</HintPath>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\packages\Microsoft.Net.Http.2.2.15\lib\net45\System.Net.Http.Primitives.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Net.Http.WebRequest" />
|
<Reference Include="System.Net.Http.WebRequest" />
|
||||||
<Reference Include="xunit">
|
<Reference Include="xunit">
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using PocketSharp.Models;
|
using PocketSharp.Models;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace PocketSharp.Tests
|
namespace PocketSharp.Tests
|
||||||
{
|
{
|
||||||
@@ -42,5 +42,18 @@ namespace PocketSharp.Tests
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task IsBodyOnlyProperlyResolved()
|
||||||
|
{
|
||||||
|
PocketArticle result = await reader.Read(new PocketItem()
|
||||||
|
{
|
||||||
|
ID = 99,
|
||||||
|
Uri = new Uri("http://calebjacob.com/tooltipster/")
|
||||||
|
});
|
||||||
|
|
||||||
|
Assert.True(result.Content.Substring(0, 4) == "<div");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
<bindingRedirect oldVersion="0.0.0.0-4.2.13.0" newVersion="4.2.13.0" />
|
<bindingRedirect oldVersion="0.0.0.0-4.2.15.0" newVersion="4.2.15.0" />
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
</assemblyBinding>
|
</assemblyBinding>
|
||||||
</runtime>
|
</runtime>
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
<package id="Microsoft.Bcl" version="1.1.3" targetFramework="net45" />
|
<package id="Microsoft.Bcl" version="1.1.3" targetFramework="net45" />
|
||||||
<package id="Microsoft.Bcl.Async" version="1.0.16" targetFramework="net45" />
|
<package id="Microsoft.Bcl.Async" version="1.0.16" targetFramework="net45" />
|
||||||
<package id="Microsoft.Bcl.Build" version="1.0.10" targetFramework="net45" />
|
<package id="Microsoft.Bcl.Build" version="1.0.10" targetFramework="net45" />
|
||||||
<package id="Microsoft.Net.Http" version="2.2.13" targetFramework="net45" />
|
<package id="Microsoft.Net.Http" version="2.2.15" targetFramework="net45" />
|
||||||
<package id="xunit" version="1.9.2" targetFramework="net45" />
|
<package id="xunit" version="1.9.2" targetFramework="net45" />
|
||||||
</packages>
|
</packages>
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
<p class="app-description">
|
<p class="app-description">
|
||||||
PocketSharp is a C#.NET class library, that integrates the Pocket API v3
|
PocketSharp is a C#.NET class library, that integrates the Pocket API v3
|
||||||
<br><br>
|
<br><br>
|
||||||
Current version: <b>1.5.1</b><br>
|
Current version: <b>2.0.1</b><br>
|
||||||
<a href="https://www.nuget.org/packages/PocketSharp/">@ nuget</a>
|
<a href="https://www.nuget.org/packages/PocketSharp/">@ nuget</a>
|
||||||
</p>
|
</p>
|
||||||
<div class="app-nuget">
|
<div class="app-nuget">
|
||||||
@@ -48,10 +48,11 @@
|
|||||||
<div class="app-main">
|
<div class="app-main">
|
||||||
<nav class="app-nav">
|
<nav class="app-nav">
|
||||||
<a href="#" data-id="gettingstarted" class="is-active">Getting Started</a>
|
<a href="#" data-id="gettingstarted" class="is-active">Getting Started</a>
|
||||||
<a href="#" data-id="account">Account</a>
|
|
||||||
<a href="#" data-id="get">Get</a>
|
<a href="#" data-id="get">Get</a>
|
||||||
<a href="#" data-id="add">Add</a>
|
<a href="#" data-id="add">Add</a>
|
||||||
|
<a href="#" data-id="reader">Reader</a>
|
||||||
<a href="#" data-id="modify">Modify</a>
|
<a href="#" data-id="modify">Modify</a>
|
||||||
|
<a href="#" data-id="account">Account</a>
|
||||||
</nav>
|
</nav>
|
||||||
<article class="article">
|
<article class="article">
|
||||||
|
|
||||||
@@ -125,6 +126,8 @@ using PocketSharp.Models;</code></pre>
|
|||||||
|
|
||||||
<h2>Release History</h2>
|
<h2>Release History</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><b>2.0.1</b> (2013-10-19) Catch HttpRequestExceptions and provide as InnerException for PocketException + Read Article from URI (method overload)</li>
|
||||||
|
<li><b>2.0.0</b> (2013-10-17) Add Reader API</li>
|
||||||
<li><b>1.5.1</b> (2013-09-30) <code>RetrieveFilter.All</code> didn't work; improve search speed</li>
|
<li><b>1.5.1</b> (2013-09-30) <code>RetrieveFilter.All</code> didn't work; improve search speed</li>
|
||||||
<li><b>1.5.0</b> (2013-09-28) add statistics and registration API</li>
|
<li><b>1.5.0</b> (2013-09-28) add statistics and registration API</li>
|
||||||
<li><b>1.4.0</b> (2013-09-21) rename <code>Retrieve</code> to <code>Get</code> + update IntelliSense documentation + add <code>GetTags</code> method</li>
|
<li><b>1.4.0</b> (2013-09-21) rename <code>Retrieve</code> to <code>Get</code> + update IntelliSense documentation + add <code>GetTags</code> method</li>
|
||||||
@@ -314,6 +317,40 @@ Accepts four parameters, with <code>uri</code> being required.
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div data-part="reader">
|
||||||
|
<h2>Article Reader API</h2>
|
||||||
|
<p>PocketSharp 2.0 implements a new <strong>Reader API</strong>.</p>
|
||||||
|
<p>This API does _not _use the official (and private) Article View API by Pocket. It is based on a custom PCL port of NReadability and SgmlReader, which are included in the solution.</p>
|
||||||
|
<h3>What's it all about?</h3>
|
||||||
|
<p>The Reader API extracts the main content of a website and returns the extracted content as HTML and it's associated title (which should already be available in the <code>PocketItem</code>).</p>
|
||||||
|
<p>This content can be encapsulated in a <code><body></code>-Tag and displayed as a readable website with a custom CSS (it's up to you!).</p>
|
||||||
|
<h3>Implementation</h3>
|
||||||
|
<p>As with all PocketSharp implementations you have to require the main namespace and it's model namespace:</p>
|
||||||
|
<p><pre class="language-clike"><code>using PocketSharp;
|
||||||
|
using PocketSharp.Models;</code></pre></p>
|
||||||
|
<p>The <code>PocketReader</code> is a seperated class with it's own <code>HttpClient</code>. Create an instance of it:</p>
|
||||||
|
<p><pre class="language-clike"><code>PocketReader reader = new PocketReader();</code></pre></p>
|
||||||
|
<p><code>PocketReader</code> needs a <code>PocketItem</code> as a parameter to correctly identify its <code>ID</code> and <code>Uri</code>. With this requirement you can successfully query for an articles content.<br>
|
||||||
|
Don't forget exception handling in case a website is down or not accessible.</p>
|
||||||
|
<p><pre class="language-clike"><code>PocketArticle article;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
article = await reader.Read(myPocketItem);
|
||||||
|
// PocketArticle: {
|
||||||
|
// int PocketItemID
|
||||||
|
// string Content
|
||||||
|
// string Title
|
||||||
|
// string NextPageUrl
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
catch (PocketException exc)
|
||||||
|
{
|
||||||
|
// handle exception
|
||||||
|
}
|
||||||
|
</code></pre></p>
|
||||||
|
|
||||||
|
</di>
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ Global
|
|||||||
{817200C3-A327-4E35-9B5F-63A51C088577}.Release|x86.ActiveCfg = Release|Any CPU
|
{817200C3-A327-4E35-9B5F-63A51C088577}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||||
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|x86.ActiveCfg = Debug|Any CPU
|
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
|||||||
@@ -65,36 +65,51 @@ namespace PocketSharp
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Requests the access code after authentication
|
/// Requests the access code after authentication
|
||||||
/// The access code has to permanently be stored within the users session, and should be added as a parameter for all future PocketClient initializations.
|
/// The access code has to permanently be stored within the users session, and should be passed in the constructor for all future PocketClient initializations.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="requestCode">The requestCode. If no requestCode is supplied, the property from the PocketClient intialization is used.</param>
|
/// <param name="requestCode">The requestCode. If no requestCode is supplied, the property from the PocketClient intialization is used.</param>
|
||||||
/// <returns>The permanent access code, which is used to authenticate the user with the application</returns>
|
/// <returns>The permanent access code, which is used to authenticate the user with the application</returns>
|
||||||
/// <exception cref="System.NullReferenceException">Call GetRequestCode() first to receive a request_code</exception>
|
/// <exception cref="System.NullReferenceException">Call GetRequestCode() first to receive a request_code</exception>
|
||||||
/// <exception cref="PocketException"></exception>
|
/// <exception cref="PocketException"></exception>
|
||||||
|
[Obsolete("Please use GetUser instead")]
|
||||||
public async Task<string> GetAccessCode(string requestCode = null)
|
public async Task<string> GetAccessCode(string requestCode = null)
|
||||||
|
{
|
||||||
|
await GetUser(requestCode);
|
||||||
|
return AccessCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Requests the access code and username after authentication
|
||||||
|
/// The access code has to permanently be stored within the users session, and should be passed in the constructor for all future PocketClient initializations.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestCode">The request code.</param>
|
||||||
|
/// <returns>The authenticated user</returns>
|
||||||
|
/// <exception cref="System.NullReferenceException">Call GetRequestCode() first to receive a request_code</exception>
|
||||||
|
public async Task<PocketUser> GetUser(string requestCode = null)
|
||||||
{
|
{
|
||||||
// check if request code is available
|
// check if request code is available
|
||||||
if(RequestCode == null && requestCode == null)
|
if (RequestCode == null && requestCode == null)
|
||||||
{
|
{
|
||||||
throw new NullReferenceException("Call GetRequestCode() first to receive a request_code");
|
throw new NullReferenceException("Call GetRequestCode() first to receive a request_code");
|
||||||
}
|
}
|
||||||
|
|
||||||
// override property with given param if available
|
// override property with given param if available
|
||||||
if(requestCode != null)
|
if (requestCode != null)
|
||||||
{
|
{
|
||||||
RequestCode = requestCode;
|
RequestCode = requestCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do request
|
// do request
|
||||||
AccessCode response = await Request<AccessCode>("oauth/authorize", new Dictionary<string, string>()
|
PocketUser response = await Request<PocketUser>("oauth/authorize", new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
{ "code", RequestCode }
|
{"code", RequestCode}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
// save code to client
|
// save code to client
|
||||||
AccessCode = response.Code;
|
AccessCode = response.Code;
|
||||||
|
|
||||||
return AccessCode;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,13 +11,22 @@ namespace PocketSharp
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class PocketClient
|
public partial class PocketClient
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves items from pocket
|
/// Retrieves items from pocket
|
||||||
/// with the given filters
|
/// with the given filters
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parameters">parameters, which are mapped to the officials from http://getpocket.com/developer/docs/v3/retrieve </param>
|
/// <param name="state">The state.</param>
|
||||||
/// <returns></returns>
|
/// <param name="favorite">The favorite.</param>
|
||||||
/// <exception cref="PocketException"></exception>
|
/// <param name="tag">The tag.</param>
|
||||||
|
/// <param name="contentType">Type of the content.</param>
|
||||||
|
/// <param name="sort">The sort.</param>
|
||||||
|
/// <param name="search">The search.</param>
|
||||||
|
/// <param name="domain">The domain.</param>
|
||||||
|
/// <param name="since">The since.</param>
|
||||||
|
/// <param name="count">The count.</param>
|
||||||
|
/// <param name="offset">The offset.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="PocketException"></exception>
|
||||||
public async Task<List<PocketItem>> Get(
|
public async Task<List<PocketItem>> Get(
|
||||||
State? state = null,
|
State? state = null,
|
||||||
bool? favorite = null,
|
bool? favorite = null,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using PocketSharp.Models;
|
using PocketSharp.Models;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace PocketSharp
|
namespace PocketSharp
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using PocketSharp.Models;
|
using PocketSharp.Models;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace PocketSharp
|
namespace PocketSharp
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,9 +14,50 @@ namespace PocketSharp
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="PocketException"></exception>
|
/// <exception cref="PocketException"></exception>
|
||||||
public async Task<PocketStatistics> Statistics()
|
public async Task<PocketStatistics> GetUserStatistics()
|
||||||
{
|
{
|
||||||
return await Request<PocketStatistics>("stats");
|
return await Request<PocketStatistics>("stats");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Statistics from the user account.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="PocketException"></exception>
|
||||||
|
[Obsolete("Please use GetUserStatistics instead")]
|
||||||
|
public async Task<PocketStatistics> Statistics()
|
||||||
|
{
|
||||||
|
return await GetUserStatistics();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns API usage statistics.
|
||||||
|
/// If a request was made before, the data is returned synchronously from the cache.
|
||||||
|
/// Note: This method only works for authenticated users with a given AccessCode.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="PocketException"></exception>
|
||||||
|
public async Task<PocketLimits> GetUsageLimits()
|
||||||
|
{
|
||||||
|
string rateLimitForConsumerKey = TryGetHeaderValue(lastHeaders, "X-Limit-Key-Limit");
|
||||||
|
|
||||||
|
if (rateLimitForConsumerKey == null)
|
||||||
|
{
|
||||||
|
// this is the fastest way to do a non-failing request to receive the correct headers
|
||||||
|
await Get(count: 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new PocketLimits()
|
||||||
|
{
|
||||||
|
RateLimitForConsumerKey = Convert.ToInt32(TryGetHeaderValue(lastHeaders, "X-Limit-Key-Limit")),
|
||||||
|
RemainingCallsForConsumerKey = Convert.ToInt32(TryGetHeaderValue(lastHeaders, "X-Limit-Key-Remaining")),
|
||||||
|
SecondsUntilLimitResetsForConsumerKey = Convert.ToInt32(TryGetHeaderValue(lastHeaders, "X-Limit-Key-Reset")),
|
||||||
|
RateLimitForUser = Convert.ToInt32(TryGetHeaderValue(lastHeaders, "X-Limit-User-Limit")),
|
||||||
|
RemainingCallsForUser = Convert.ToInt32(TryGetHeaderValue(lastHeaders, "X-Limit-User-Remaining")),
|
||||||
|
SecondsUntilLimitResetsForUser = Convert.ToInt32(TryGetHeaderValue(lastHeaders, "X-Limit-User-Reset"))
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Choose>
|
||||||
|
<When Condition="$(NCrunchOriginalSolutionDir) != '' And $(NCrunchOriginalSolutionDir) != '*Undefined*'">
|
||||||
|
<PropertyGroup>
|
||||||
|
<FodySolutionDir>$(NCrunchOriginalSolutionDir)</FodySolutionDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
</When>
|
||||||
|
<When Condition="$(SolutionDir) != '' And $(SolutionDir) != '*Undefined*'">
|
||||||
|
<PropertyGroup>
|
||||||
|
<FodySolutionDir>$(SolutionDir)</FodySolutionDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
</When>
|
||||||
|
<When Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">
|
||||||
|
<PropertyGroup>
|
||||||
|
<FodySolutionDir>$(MSBuildProjectDirectory)\..\</FodySolutionDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
</When>
|
||||||
|
</Choose>
|
||||||
|
<Choose>
|
||||||
|
<When Condition="$(KeyOriginatorFile) != '' And $(KeyOriginatorFile) != '*Undefined*'">
|
||||||
|
<PropertyGroup>
|
||||||
|
<FodyKeyFilePath>$(KeyOriginatorFile)</FodyKeyFilePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
</When>
|
||||||
|
<When Condition="$(AssemblyOriginatorKeyFile) != '' And $(AssemblyOriginatorKeyFile) != '*Undefined*'">
|
||||||
|
<PropertyGroup>
|
||||||
|
<FodyKeyFilePath>$(AssemblyOriginatorKeyFile)</FodyKeyFilePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
</When>
|
||||||
|
<Otherwise >
|
||||||
|
<PropertyGroup>
|
||||||
|
<FodyKeyFilePath></FodyKeyFilePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Otherwise>
|
||||||
|
</Choose>
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntermediateDir>$(ProjectDir)$(IntermediateOutputPath)</IntermediateDir>
|
||||||
|
<FodyMessageImportance Condition="$(FodyMessageImportance) == '' Or $(FodyMessageImportance) == '*Undefined*'">Low</FodyMessageImportance>
|
||||||
|
<FodySignAssembly Condition="$(FodySignAssembly) == '' Or $(FodySignAssembly) == '*Undefined*'">$(SignAssembly)</FodySignAssembly>
|
||||||
|
<FodyPath Condition="$(FodyPath) == '' Or $(FodyPath) == '*Undefined*'">$(MSBuildThisFileDirectory)</FodyPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<UsingTask
|
||||||
|
TaskName="Fody.WeavingTask"
|
||||||
|
AssemblyFile="$(FodyPath)\Fody.dll" />
|
||||||
|
<Target
|
||||||
|
AfterTargets="AfterCompile"
|
||||||
|
Name="WinFodyTarget"
|
||||||
|
Condition=" '$(OS)' == 'Windows_NT'">
|
||||||
|
|
||||||
|
<Fody.WeavingTask
|
||||||
|
AssemblyPath="@(IntermediateAssembly)"
|
||||||
|
IntermediateDir="$(IntermediateDir)"
|
||||||
|
KeyFilePath="$(FodyKeyFilePath)"
|
||||||
|
MessageImportance="$(FodyMessageImportance)"
|
||||||
|
ProjectDirectory="$(ProjectDir)"
|
||||||
|
SolutionDir="$(FodySolutionDir)"
|
||||||
|
References="@(ReferencePath)"
|
||||||
|
SignAssembly="$(FodySignAssembly)"
|
||||||
|
ReferenceCopyLocalPaths="@(ReferenceCopyLocalPaths)"
|
||||||
|
DefineConstants="$(DefineConstants)"
|
||||||
|
/>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target
|
||||||
|
AfterTargets="AfterBuild"
|
||||||
|
Name="NonWinFodyTarget"
|
||||||
|
Condition=" '$(OS)' != 'Windows_NT'">
|
||||||
|
<Fody.WeavingTask
|
||||||
|
AssemblyPath="$(TargetPath)"
|
||||||
|
IntermediateDir="$(IntermediateDir)"
|
||||||
|
KeyFilePath="$(FodyKeyFilePath)"
|
||||||
|
MessageImportance="$(FodyMessageImportance)"
|
||||||
|
ProjectDirectory="$(ProjectDir)"
|
||||||
|
SolutionDir="$(FodySolutionDir)"
|
||||||
|
References="@(ReferencePath)"
|
||||||
|
SignAssembly="$(FodySignAssembly)"
|
||||||
|
ReferenceCopyLocalPaths="$(ReferenceCopyLocalPaths)"
|
||||||
|
DefineConstants="$(DefineConstants)"
|
||||||
|
/>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
|
||||||
|
<!--Support for ncrunch-->
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="$(FodyPath)\*.*" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Weavers>
|
||||||
|
<PropertyChanged />
|
||||||
|
</Weavers>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using System.Reflection;
|
|||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
using System;
|
using System.Runtime.Serialization;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using PropertyChanged;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Readable article
|
/// Readable article
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[ImplementPropertyChanged]
|
||||||
public class PocketArticle
|
public class PocketArticle
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -40,6 +39,6 @@ namespace PocketSharp.Models
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The next page URL.
|
/// The next page URL.
|
||||||
/// </value>
|
/// </value>
|
||||||
public string NextPageUrl { get; set; }
|
public Uri NextPage { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.Serialization;
|
using PropertyChanged;
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
@@ -8,6 +8,7 @@ namespace PocketSharp.Models
|
|||||||
/// Author
|
/// Author
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
|
[ImplementPropertyChanged]
|
||||||
public class PocketAuthor
|
public class PocketAuthor
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.Serialization;
|
using PropertyChanged;
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
@@ -8,6 +8,7 @@ namespace PocketSharp.Models
|
|||||||
/// Image
|
/// Image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
|
[ImplementPropertyChanged]
|
||||||
public class PocketImage
|
public class PocketImage
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.Serialization;
|
using PropertyChanged;
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
@@ -10,6 +10,7 @@ namespace PocketSharp.Models
|
|||||||
/// see: http://getpocket.com/developer/docs/v3/retrieve
|
/// see: http://getpocket.com/developer/docs/v3/retrieve
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
|
[ImplementPropertyChanged]
|
||||||
public class PocketItem
|
public class PocketItem
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using PropertyChanged;
|
||||||
|
|
||||||
|
namespace PocketSharp.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// API Limitation Statistics
|
||||||
|
/// </summary>
|
||||||
|
[JsonObject]
|
||||||
|
[ImplementPropertyChanged]
|
||||||
|
public class PocketLimits
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the rate limit.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// Rate limit for current consumer key.
|
||||||
|
/// </value>
|
||||||
|
[JsonProperty("X-Limit-Key-Limit")]
|
||||||
|
public int RateLimitForConsumerKey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the remaining calls.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// Remaining calls for current consumer key.
|
||||||
|
/// </value>
|
||||||
|
[JsonProperty("X-Limit-Key-Remaining")]
|
||||||
|
public int RemainingCallsForConsumerKey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the reset seconds.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// Seconds until limit resets for current consumer key.
|
||||||
|
/// </value>
|
||||||
|
[JsonProperty("X-Limit-Key-Reset")]
|
||||||
|
public int SecondsUntilLimitResetsForConsumerKey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the rate limit.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// Rate limit for current user.
|
||||||
|
/// </value>
|
||||||
|
[JsonProperty("X-Limit-User-Limit")]
|
||||||
|
public int RateLimitForUser { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the remaining calls.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// Remaining calls for current user.
|
||||||
|
/// </value>
|
||||||
|
[JsonProperty("X-Limit-User-Remaining")]
|
||||||
|
public int RemainingCallsForUser { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the reset seconds.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// Seconds until limit resets for current user.
|
||||||
|
/// </value>
|
||||||
|
[JsonProperty("X-Limit-User-Reset")]
|
||||||
|
public int SecondsUntilLimitResetsForUser { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Runtime.Serialization;
|
using PropertyChanged;
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
@@ -7,6 +7,7 @@ namespace PocketSharp.Models
|
|||||||
/// Statistics
|
/// Statistics
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
|
[ImplementPropertyChanged]
|
||||||
public class PocketStatistics
|
public class PocketStatistics
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,21 +1,22 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Runtime.Serialization;
|
using PropertyChanged;
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Tag
|
|
||||||
/// </summary>
|
|
||||||
[JsonObject]
|
|
||||||
public class PocketTag
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the name.
|
/// Tag
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>
|
[JsonObject]
|
||||||
/// The name.
|
[ImplementPropertyChanged]
|
||||||
/// </value>
|
public class PocketTag
|
||||||
[JsonProperty("tag")]
|
{
|
||||||
public string Name { get; set; }
|
/// <summary>
|
||||||
}
|
/// Gets or sets the name.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The name.
|
||||||
|
/// </value>
|
||||||
|
[JsonProperty("tag")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Runtime.Serialization;
|
using PropertyChanged;
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
@@ -7,7 +7,8 @@ namespace PocketSharp.Models
|
|||||||
/// Access Code
|
/// Access Code
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
internal class AccessCode
|
[ImplementPropertyChanged]
|
||||||
|
public class PocketUser
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the code.
|
/// Gets or sets the code.
|
||||||
@@ -24,7 +25,7 @@ namespace PocketSharp.Models
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The username.
|
/// The username.
|
||||||
/// </value>
|
/// </value>
|
||||||
[JsonProperty]
|
[JsonProperty("username")]
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,40 +1,41 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.Serialization;
|
using PropertyChanged;
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Video
|
|
||||||
/// </summary>
|
|
||||||
[JsonObject]
|
|
||||||
public class PocketVideo
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the ID.
|
/// Video
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>
|
[JsonObject]
|
||||||
/// The ID.
|
[ImplementPropertyChanged]
|
||||||
/// </value>
|
public class PocketVideo
|
||||||
[JsonProperty("video_id")]
|
{
|
||||||
public string ID { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the ID.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The ID.
|
||||||
|
/// </value>
|
||||||
|
[JsonProperty("video_id")]
|
||||||
|
public string ID { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the external ID.
|
/// Gets or sets the external ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>
|
/// <value>
|
||||||
/// The external ID.
|
/// The external ID.
|
||||||
/// </value>
|
/// </value>
|
||||||
[JsonProperty("vid")]
|
[JsonProperty("vid")]
|
||||||
public string ExternalID { get; set; }
|
public string ExternalID { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the URI.
|
/// Gets or sets the URI.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>
|
/// <value>
|
||||||
/// The URI.
|
/// The URI.
|
||||||
/// </value>
|
/// </value>
|
||||||
[JsonProperty("src")]
|
[JsonProperty("src")]
|
||||||
public Uri Uri { get; set; }
|
public Uri Uri { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace PocketSharp.Models
|
namespace PocketSharp.Models
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ using System.Net;
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using Newtonsoft.Json.Serialization;
|
using Newtonsoft.Json.Serialization;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
|
|
||||||
namespace PocketSharp
|
namespace PocketSharp
|
||||||
@@ -22,6 +20,11 @@ namespace PocketSharp
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly HttpClient _restClient;
|
protected readonly HttpClient _restClient;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Caches HTTP headers from last response
|
||||||
|
/// </summary>
|
||||||
|
private HttpResponseHeaders lastHeaders;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The base URL for the Pocket API
|
/// The base URL for the Pocket API
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -35,7 +38,7 @@ namespace PocketSharp
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// callback URL for API calls
|
/// callback URL for API calls
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected string CallbackUri { get; set; }
|
public string CallbackUri { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Accessor for the Pocket API key
|
/// Accessor for the Pocket API key
|
||||||
@@ -54,6 +57,7 @@ namespace PocketSharp
|
|||||||
public string AccessCode { get; set; }
|
public string AccessCode { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="PocketClient"/> class.
|
/// Initializes a new instance of the <see cref="PocketClient"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -112,6 +116,7 @@ namespace PocketSharp
|
|||||||
|
|
||||||
// every single Pocket API endpoint requires HTTP POST data
|
// every single Pocket API endpoint requires HTTP POST data
|
||||||
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, method);
|
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, method);
|
||||||
|
HttpResponseMessage response = null;
|
||||||
|
|
||||||
if (parameters == null)
|
if (parameters == null)
|
||||||
{
|
{
|
||||||
@@ -131,11 +136,21 @@ namespace PocketSharp
|
|||||||
request.Content = new FormUrlEncodedContent(parameters);
|
request.Content = new FormUrlEncodedContent(parameters);
|
||||||
|
|
||||||
// make async request
|
// make async request
|
||||||
HttpResponseMessage response = await _restClient.SendAsync(request);
|
try
|
||||||
|
{
|
||||||
|
response = await _restClient.SendAsync(request);
|
||||||
|
}
|
||||||
|
catch (HttpRequestException exc)
|
||||||
|
{
|
||||||
|
throw new PocketException(exc.Message, exc);
|
||||||
|
}
|
||||||
|
|
||||||
// validate HTTP response
|
// validate HTTP response
|
||||||
ValidateResponse(response);
|
ValidateResponse(response);
|
||||||
|
|
||||||
|
// cache headers
|
||||||
|
lastHeaders = response.Headers;
|
||||||
|
|
||||||
// read response
|
// read response
|
||||||
var responseString = await response.Content.ReadAsStringAsync();
|
var responseString = await response.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
@@ -259,6 +274,11 @@ namespace PocketSharp
|
|||||||
{
|
{
|
||||||
string result = null;
|
string result = null;
|
||||||
|
|
||||||
|
if (headers == null || String.IsNullOrEmpty(key))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var header in headers)
|
foreach (var header in headers)
|
||||||
{
|
{
|
||||||
if (header.Key == key)
|
if (header.Key == key)
|
||||||
@@ -267,6 +287,7 @@ namespace PocketSharp
|
|||||||
headerEnumerator.MoveNext();
|
headerEnumerator.MoveNext();
|
||||||
|
|
||||||
result = headerEnumerator.Current;
|
result = headerEnumerator.Current;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,26 @@ namespace PocketSharp
|
|||||||
_httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Encoding", "gzip,deflate");
|
_httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Encoding", "gzip,deflate");
|
||||||
|
|
||||||
// add user agent (default for Opera with PocketSharp identifier appended)
|
// add user agent (default for Opera with PocketSharp identifier appended)
|
||||||
_httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.4 Safari/537.36 OPR/18.0.1284.2 PocketSharp/2.0");
|
_httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.4 Safari/537.36 OPR/18.0.1284.2 PocketSharp/2.2");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads article content from the given URI.
|
||||||
|
/// This method does not use the official Article View API, which is private.
|
||||||
|
/// The PocketReader is based on a custom PCL port of NReadability and SgmlReader.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uri">An URI.</param>
|
||||||
|
/// <returns>A Pocket article with extracted content and title.</returns>
|
||||||
|
/// <exception cref="PocketRequestException"></exception>
|
||||||
|
public async Task<PocketArticle> Read(Uri uri)
|
||||||
|
{
|
||||||
|
return await Read(new PocketItem()
|
||||||
|
{
|
||||||
|
ID = 0,
|
||||||
|
Uri = uri
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -49,7 +68,7 @@ namespace PocketSharp
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The pocket item.</param>
|
/// <param name="item">The pocket item.</param>
|
||||||
/// <returns>A Pocket article with extracted content and title.</returns>
|
/// <returns>A Pocket article with extracted content and title.</returns>
|
||||||
/// <exception cref="PocketException"></exception>
|
/// <exception cref="PocketRequestException"></exception>
|
||||||
public async Task<PocketArticle> Read(PocketItem item)
|
public async Task<PocketArticle> Read(PocketItem item)
|
||||||
{
|
{
|
||||||
// initialize transcoder
|
// initialize transcoder
|
||||||
@@ -87,7 +106,7 @@ namespace PocketSharp
|
|||||||
{
|
{
|
||||||
Content = transcodingResult.ExtractedContent,
|
Content = transcodingResult.ExtractedContent,
|
||||||
Title = transcodingResult.ExtractedTitle,
|
Title = transcodingResult.ExtractedTitle,
|
||||||
NextPageUrl = transcodingResult.NextPageUrl,
|
NextPage = transcodingResult.NextPageUrl != null ? new Uri(transcodingResult.NextPageUrl, UriKind.Absolute) : null,
|
||||||
PocketItemID = item.ID
|
PocketItemID = item.ID
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -102,9 +121,17 @@ namespace PocketSharp
|
|||||||
protected async Task<string> Request(Uri uri)
|
protected async Task<string> Request(Uri uri)
|
||||||
{
|
{
|
||||||
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, uri);
|
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, uri);
|
||||||
|
HttpResponseMessage response = null;
|
||||||
|
|
||||||
// make async request
|
// make async request
|
||||||
HttpResponseMessage response = await _httpClient.SendAsync(request);
|
try
|
||||||
|
{
|
||||||
|
response = await _httpClient.SendAsync(request);
|
||||||
|
}
|
||||||
|
catch (HttpRequestException exc)
|
||||||
|
{
|
||||||
|
throw new PocketException(exc.Message, exc);
|
||||||
|
}
|
||||||
|
|
||||||
// validate HTTP response
|
// validate HTTP response
|
||||||
if (response.StatusCode != HttpStatusCode.OK)
|
if (response.StatusCode != HttpStatusCode.OK)
|
||||||
@@ -115,9 +142,7 @@ namespace PocketSharp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// read response
|
// read response
|
||||||
var responseString = await response.Content.ReadAsStringAsync();
|
return await response.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
return responseString;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,11 +11,12 @@
|
|||||||
<RootNamespace>PocketSharp</RootNamespace>
|
<RootNamespace>PocketSharp</RootNamespace>
|
||||||
<AssemblyName>PocketSharp</AssemblyName>
|
<AssemblyName>PocketSharp</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
<TargetFrameworkProfile>Profile104</TargetFrameworkProfile>
|
<TargetFrameworkProfile>Profile96</TargetFrameworkProfile>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||||
<RestorePackages>true</RestorePackages>
|
<RestorePackages>true</RestorePackages>
|
||||||
|
<FodyPath>..\packages\Fody.1.17.4.0</FodyPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
@@ -36,20 +37,22 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- A reference to the entire .NET Framework is automatically included -->
|
<!-- A reference to the entire .NET Framework is automatically included -->
|
||||||
|
<None Include="Fody.targets" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Components\Statistics.cs" />
|
<Compile Include="Components\Statistics.cs" />
|
||||||
<Compile Include="Models\Parameters\RegisterParameters.cs" />
|
<Compile Include="Models\Parameters\RegisterParameters.cs" />
|
||||||
<Compile Include="Models\PocketArticle.cs" />
|
<Compile Include="Models\PocketArticle.cs" />
|
||||||
|
<Compile Include="Models\PocketLimits.cs" />
|
||||||
<Compile Include="Models\PocketStatistics.cs" />
|
<Compile Include="Models\PocketStatistics.cs" />
|
||||||
<Compile Include="PocketException.cs" />
|
<Compile Include="Utilities\PocketException.cs" />
|
||||||
<Compile Include="Components\Add.cs" />
|
<Compile Include="Components\Add.cs" />
|
||||||
<Compile Include="Components\Account.cs" />
|
<Compile Include="Components\Account.cs" />
|
||||||
<Compile Include="Components\Modify.cs" />
|
<Compile Include="Components\Modify.cs" />
|
||||||
<Compile Include="Components\ModifyTags.cs" />
|
<Compile Include="Components\ModifyTags.cs" />
|
||||||
<Compile Include="Components\Get.cs" />
|
<Compile Include="Components\Get.cs" />
|
||||||
<Compile Include="JsonExtensions.cs" />
|
<Compile Include="Utilities\JsonExtensions.cs" />
|
||||||
<Compile Include="Models\Parameters\ActionParameter.cs" />
|
<Compile Include="Models\Parameters\ActionParameter.cs" />
|
||||||
<Compile Include="Models\Parameters\AddParameters.cs" />
|
<Compile Include="Models\Parameters\AddParameters.cs" />
|
||||||
<Compile Include="Models\Parameters\ModifyParameters.cs" />
|
<Compile Include="Models\Parameters\ModifyParameters.cs" />
|
||||||
@@ -60,7 +63,7 @@
|
|||||||
<Compile Include="Models\PocketItem.cs" />
|
<Compile Include="Models\PocketItem.cs" />
|
||||||
<Compile Include="Models\PocketTag.cs" />
|
<Compile Include="Models\PocketTag.cs" />
|
||||||
<Compile Include="Models\PocketVideo.cs" />
|
<Compile Include="Models\PocketVideo.cs" />
|
||||||
<Compile Include="Models\Response\AccessCode.cs" />
|
<Compile Include="Models\PocketUser.cs" />
|
||||||
<Compile Include="Models\Response\Add.cs" />
|
<Compile Include="Models\Response\Add.cs" />
|
||||||
<Compile Include="Models\Response\Modify.cs" />
|
<Compile Include="Models\Response\Modify.cs" />
|
||||||
<Compile Include="Models\Response\RequestCode.cs" />
|
<Compile Include="Models\Response\RequestCode.cs" />
|
||||||
@@ -69,7 +72,7 @@
|
|||||||
<Compile Include="PocketClient.cs" />
|
<Compile Include="PocketClient.cs" />
|
||||||
<Compile Include="PocketReader.cs" />
|
<Compile Include="PocketReader.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Utilities.cs" />
|
<Compile Include="Utilities\Utilities.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.Threading.Tasks">
|
<Reference Include="Microsoft.Threading.Tasks">
|
||||||
@@ -81,6 +84,10 @@
|
|||||||
<Reference Include="Newtonsoft.Json">
|
<Reference Include="Newtonsoft.Json">
|
||||||
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\portable-net40+sl4+wp7+win8\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\portable-net40+sl4+wp7+win8\Newtonsoft.Json.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="PropertyChanged">
|
||||||
|
<HintPath>..\packages\PropertyChanged.Fody.1.41.0.0\Lib\portable-net4+sl4+wp7+win8+MonoAndroid16+MonoTouch40\PropertyChanged.dll</HintPath>
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.IO">
|
<Reference Include="System.IO">
|
||||||
<HintPath>..\packages\Microsoft.Bcl.1.1.3\lib\portable-net40+sl4+win8+wp71\System.IO.dll</HintPath>
|
<HintPath>..\packages\Microsoft.Bcl.1.1.3\lib\portable-net40+sl4+win8+wp71\System.IO.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -100,6 +107,9 @@
|
|||||||
<HintPath>..\packages\Microsoft.Bcl.1.1.3\lib\portable-net40+sl4+win8+wp71\System.Threading.Tasks.dll</HintPath>
|
<HintPath>..\packages\Microsoft.Bcl.1.1.3\lib\portable-net40+sl4+win8+wp71\System.Threading.Tasks.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="FodyWeavers.xml" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\PortablePorts\NReadability\NReadability.csproj">
|
<ProjectReference Include="..\PortablePorts\NReadability\NReadability.csproj">
|
||||||
<Project>{14c3ee6a-54a4-4a37-8b56-d52a3802f1c2}</Project>
|
<Project>{14c3ee6a-54a4-4a37-8b56-d52a3802f1c2}</Project>
|
||||||
@@ -119,6 +129,7 @@
|
|||||||
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
|
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
|
||||||
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
|
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
|
||||||
</Target>
|
</Target>
|
||||||
|
<Import Project="Fody.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
|
|||||||
@@ -8,16 +8,16 @@
|
|||||||
<owners>$author$</owners>
|
<owners>$author$</owners>
|
||||||
<licenseUrl>https://raw.github.com/ceee/PocketSharp/master/LICENSE-MIT</licenseUrl>
|
<licenseUrl>https://raw.github.com/ceee/PocketSharp/master/LICENSE-MIT</licenseUrl>
|
||||||
<projectUrl>http://pocketsharp.frontendplay.com</projectUrl>
|
<projectUrl>http://pocketsharp.frontendplay.com</projectUrl>
|
||||||
<iconUrl>http://pocketsharp.frontendplay.com/Assets/Images/pocketsharp.png</iconUrl>
|
<iconUrl>https://raw.github.com/ceee/PocketSharp/master/pocketsharp.png</iconUrl>
|
||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||||
<description>PocketSharp is a .NET class library, that integrates the Pocket API v3</description>
|
<description>PocketSharp is a C#.NET portable class library that integrates the Pocket API v3.</description>
|
||||||
<language>en-US</language>
|
<language>en-US</language>
|
||||||
<releaseNotes>
|
<releaseNotes>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
For full release notes see https://github.com/ceee/PocketSharp#release-history
|
For full release notes see https://github.com/ceee/PocketSharp/blob/master/CHANGELOG.md
|
||||||
]]>
|
]]>
|
||||||
</releaseNotes>
|
</releaseNotes>
|
||||||
<copyright>Copyright by cee, 2013</copyright>
|
<copyright>Copyright by cee, 2013</copyright>
|
||||||
<tags>PocketAPI Pocket API PocketSharp Tobias Klika cee RestSharp</tags>
|
<tags>PocketAPI Pocket API PocketSharp Tobias Klika cee NReadability Reader Article SDK Pockem</tags>
|
||||||
</metadata>
|
</metadata>
|
||||||
</package>
|
</package>
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ using System.Runtime.InteropServices;
|
|||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("PocketSharp")]
|
[assembly: AssemblyTitle("PocketSharp")]
|
||||||
[assembly: AssemblyDescription("PocketSharp is a .NET class library that integrates the Pocket API v3")]
|
[assembly: AssemblyDescription("PocketSharp is a .NET class library that integrates the Pocket API v3 (support a custom Article View API)")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("cee")]
|
[assembly: AssemblyCompany("cee")]
|
||||||
[assembly: AssemblyProduct("PocketSharp")]
|
[assembly: AssemblyProduct("PocketSharp")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
[assembly: AssemblyCopyright("Copyright © cee 2013")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
@@ -25,5 +25,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.0.0")]
|
[assembly: AssemblyVersion("2.2.1")]
|
||||||
[assembly: AssemblyFileVersion("2.0.0")]
|
[assembly: AssemblyFileVersion("2.2.1")]
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace PocketSharp
|
namespace PocketSharp
|
||||||
{
|
{
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace PocketSharp
|
namespace PocketSharp
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using PocketSharp.Models;
|
|
||||||
|
|
||||||
namespace PocketSharp
|
namespace PocketSharp
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
|
<package id="Fody" version="1.17.4.0" targetFramework="portable-net403+sl40+wp71+win" />
|
||||||
<package id="Microsoft.Bcl" version="1.1.3" targetFramework="portable-net45+sl40+wp71+win" />
|
<package id="Microsoft.Bcl" version="1.1.3" targetFramework="portable-net45+sl40+wp71+win" />
|
||||||
<package id="Microsoft.Bcl.Async" version="1.0.16" targetFramework="portable-net45+sl40+wp71+win" />
|
<package id="Microsoft.Bcl.Async" version="1.0.16" targetFramework="portable-net45+sl40+wp71+win" />
|
||||||
<package id="Microsoft.Bcl.Build" version="1.0.10" targetFramework="portable-net45+sl40+wp71+win" />
|
<package id="Microsoft.Bcl.Build" version="1.0.10" targetFramework="portable-net45+sl40+wp71+win" />
|
||||||
<package id="Microsoft.Net.Http" version="2.2.15" targetFramework="portable-net403+sl40+wp71+win" />
|
<package id="Microsoft.Net.Http" version="2.2.15" targetFramework="portable-net403+sl40+wp71+win" />
|
||||||
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="portable-net45+sl40+wp71+win" />
|
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="portable-net45+sl40+wp71+win" />
|
||||||
|
<package id="PropertyChanged.Fody" version="1.41.0.0" targetFramework="portable-net403+sl40+wp71+win" />
|
||||||
</packages>
|
</packages>
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
<RootNamespace>PocketSharp.Ports.NReadability</RootNamespace>
|
<RootNamespace>PocketSharp.Ports.NReadability</RootNamespace>
|
||||||
<AssemblyName>PocketSharp.Ports.NReadability</AssemblyName>
|
<AssemblyName>PocketSharp.Ports.NReadability</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
<TargetFrameworkProfile>Profile104</TargetFrameworkProfile>
|
<TargetFrameworkProfile>Profile96</TargetFrameworkProfile>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ namespace PocketSharp.Ports.NReadability
|
|||||||
|
|
||||||
if (domSerializationParams.BodyOnly && document.Root != null)
|
if (domSerializationParams.BodyOnly && document.Root != null)
|
||||||
{
|
{
|
||||||
var body = document.Root.GetChildrenByTagName("body").FirstOrDefault();
|
var body = document.Root.GetElementsByTagName("body").FirstOrDefault();
|
||||||
|
|
||||||
if (body != null)
|
if (body != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -397,7 +397,6 @@ namespace PocketSharp.Ports.Sgml
|
|||||||
private string m_rootElementName;
|
private string m_rootElementName;
|
||||||
|
|
||||||
private string m_href;
|
private string m_href;
|
||||||
private string m_errorLogFile;
|
|
||||||
private Entity m_lastError;
|
private Entity m_lastError;
|
||||||
private string m_proxy;
|
private string m_proxy;
|
||||||
private TextReader m_inputStream;
|
private TextReader m_inputStream;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<RootNamespace>PocketSharp.Ports.SgmlReader</RootNamespace>
|
<RootNamespace>PocketSharp.Ports.SgmlReader</RootNamespace>
|
||||||
<AssemblyName>PocketSharp.Ports.SgmlReader</AssemblyName>
|
<AssemblyName>PocketSharp.Ports.SgmlReader</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
<TargetFrameworkProfile>Profile104</TargetFrameworkProfile>
|
<TargetFrameworkProfile>Profile96</TargetFrameworkProfile>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>TRACE;DEBUG;PORTABLE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -1,69 +1,28 @@
|
|||||||

|

|
||||||
|
|
||||||
**PocketSharp** is a C#.NET class library, that integrates the [Pocket API v3](http://getpocket.com/developer).
|
**PocketSharp** is a C#.NET portable class library that integrates the [Pocket API v3](http://getpocket.com/developer).
|
||||||
|
|
||||||
**Website:** [pocketsharp.frontendplay.com](http://pocketsharp.frontendplay.com/)
|
## Install using [NuGet](https://www.nuget.org/packages/PocketSharp/)
|
||||||
<br>
|
|
||||||
**NuGet:** [nuget.org/packages/PocketSharp](https://www.nuget.org/packages/PocketSharp/)
|
|
||||||
|
|
||||||
|
|
||||||
## Install using NuGet
|
|
||||||
|
|
||||||
```
|
```
|
||||||
Install-Package PocketSharp
|
Install-Package PocketSharp
|
||||||
```
|
```
|
||||||
|
|
||||||
## Components
|
## Documentation
|
||||||
|
|
||||||
- [Get](#get) - Retrieve and search for items
|
See [wiki](https://github.com/ceee/PocketSharp/wiki)
|
||||||
- [Modify](#modify) - Modify items and its tags
|
|
||||||
- [Add](#add) - Add new items
|
|
||||||
- [Authentication](#account-authentication) - Authenticate users
|
|
||||||
- [Registration](#account-registration) - Register new users
|
|
||||||
- [Statistics](#statistics) - Retrieve account statistics
|
|
||||||
|
|
||||||
## Supported platforms
|
---
|
||||||
|
|
||||||
PocketSharp is a **Portable Class Library** (since 1.0.0), therefore it's compatible with multiple platforms:
|
## Usage Example:
|
||||||
|
|
||||||
- **.NET** >= 4.0.3 (including WPF)
|
A search for items containing `CSS`:
|
||||||
- **Silverlight** >= 4
|
|
||||||
- **Windows Phone** >= 7.5
|
|
||||||
- **Windows Store**
|
|
||||||
|
|
||||||
You can find examples for Silverlight 5, WP8 and WPF in the `PocketSharp.Examples` ([@github](https://github.com/ceee/PocketSharp/tree/master/PocketSharp.Examples)) folder.
|
|
||||||
|
|
||||||
## Async Support
|
|
||||||
|
|
||||||
All public methods, which communicate with the Pocket servers are asynchronous. So they should be called with the preceding `await` keyword, and the encapsulated method marked with `async`.
|
|
||||||
|
|
||||||
_In PocketSharp versions < 1.0.0 all methods lacked async support and were blocking._
|
|
||||||
|
|
||||||
## What's next
|
|
||||||
|
|
||||||
Next is Reading API support (with NReadability implementation). Release: Mid October.
|
|
||||||
|
|
||||||
## Usage Example
|
|
||||||
|
|
||||||
Request a [Consumer Key on Pocket.](http://getpocket.com/developer/apps/)
|
|
||||||
|
|
||||||
Include the PocketSharp namespace and it's associated models (you will need them later):
|
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
using PocketSharp;
|
PocketClient client = new PocketClient("[YOUR_CONSUMER_KEY]", "[YOUR_ACCESS_CODE]");
|
||||||
using PocketSharp.Models;
|
|
||||||
```
|
|
||||||
|
|
||||||
Initialize PocketClient with:
|
List<PocketItem> items = await client.Search("css");
|
||||||
|
|
||||||
```csharp
|
|
||||||
PocketClient _client = new PocketClient("[YOUR_CONSUMER_KEY]", "[YOUR_ACCESS_CODE]");
|
|
||||||
```
|
|
||||||
|
|
||||||
Do a simple request - e.g. a search for `CSS`:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
var items = await _client.Search("css");
|
|
||||||
items.ForEach(
|
items.ForEach(
|
||||||
item => Debug.WriteLine(item.ID + " | " + item.Title)
|
item => Debug.WriteLine(item.ID + " | " + item.Title)
|
||||||
);
|
);
|
||||||
@@ -77,293 +36,40 @@ Which will output:
|
|||||||
343693149 | CSS3 Transitions - Thank God We Have A Specification!
|
343693149 | CSS3 Transitions - Thank God We Have A Specification!
|
||||||
...
|
...
|
||||||
|
|
||||||
## Create an instance
|
|
||||||
|
|
||||||
Constructor:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
PocketClient(string consumerKey, string accessCode = null, Uri callbackUri = null)
|
|
||||||
```
|
|
||||||
|
|
||||||
`consumerKey`: The API key
|
|
||||||
<br>
|
|
||||||
`accessCode`: Provide an access code if the user is already authenticated
|
|
||||||
<br>
|
|
||||||
`callbackUri`: The callback URL is called by Pocket after authentication
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
PocketClient _client = new PocketClient(
|
|
||||||
consumerKey: "123498237423498723498723",
|
|
||||||
callbackUri: new Uri("http://ceecore.com"),
|
|
||||||
accessCode: "097809-oi987-izi8-jk98-oiuu89"
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
You can change the _Access Code_ after initialization:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
_client.AccessCode = "[YOU_ACCESS_CODE]";
|
|
||||||
```
|
|
||||||
|
|
||||||
**Before authentication** you will need to provide the `callbackUri` for authentication requests.
|
|
||||||
<br>
|
|
||||||
**After authentication** you will need to provide the `accessCode`.
|
|
||||||
|
|
||||||
## Account Authentication
|
|
||||||
|
|
||||||
In order to communicate with a Pocket User, you will need a consumer key (which is generated by [creating a new application on Pocket](http://getpocket.com/developer/apps/)) and an **Access Code**.
|
|
||||||
|
|
||||||
The authentication is a 3-step process:
|
|
||||||
|
|
||||||
#### 1) Generate authentication URI
|
|
||||||
|
|
||||||
Receive the **request code** and **authentication URI** from the library by calling `string GetRequestCode()`:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
string requestCode = await _client.GetRequestCode();
|
|
||||||
// 0f453f2d-1605-8584-28fd-39af8e
|
|
||||||
Uri authenticationUri = _client.GenerateAuthenticationUri();
|
|
||||||
// https://getpocket.com/auth/authorize?request_token=0f453f2d-1605-8584-28fd-39af8e&redirect_uri=http%253a%252f%252fceecore.com
|
|
||||||
```
|
|
||||||
|
|
||||||
The _request code_ is stored internally, but you can also provide it as param in `GenerateAuthenticationUri(string requestCode = null)`.
|
|
||||||
|
|
||||||
#### 2) Redirect to Pocket
|
|
||||||
Next you need to redirect the user to the `authenticationUri`, which displays a prompt to grant permissions for the application (see image). After the user granted or denied, he/she is redirected to the `callbackUri`.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
#### 3) Get Access Code
|
|
||||||
Call `Task<string> GetAccessCode(string requestCode = null)`
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
string accessCode = await _client.GetAccessCode();
|
|
||||||
// fa8bfc16-69b3-4d22-7db7-84a58d
|
|
||||||
```
|
|
||||||
|
|
||||||
Again, the received _access code_ is stored internally.
|
|
||||||
Note that `GetAccessCode` can only be called with an existing _request code_. If you need to re-authenticate a user, start again with Step 1).
|
|
||||||
|
|
||||||
#### Important
|
|
||||||
|
|
||||||
**Be sure to permanently store the _Access Code_ for your user.**
|
|
||||||
<br>
|
|
||||||
Without it you would always have to redo the authentication process.
|
|
||||||
|
|
||||||
## Account Registration
|
|
||||||
|
|
||||||
The `RegisterAccount` method exists in Pocket API v3, but is currently undocumented.
|
|
||||||
<br>The user cannot authenticate directly after registration, as the account has to be activated via an opt-in link, which is sent to the e-mail address.
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
bool isSuccess = await _client.RegisterAccount("myUsername", "me@mymail.com", "mypassword");
|
|
||||||
```
|
|
||||||
|
|
||||||
After registration you have to remind the user to check his/her mail account.
|
|
||||||
|
|
||||||
## Get
|
|
||||||
|
|
||||||
Get list of all items:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
List<PocketItem> items = await _client.Get();
|
|
||||||
// equivalent to: await _client.Get(RetrieveFilter.All)
|
|
||||||
```
|
|
||||||
|
|
||||||
Get a list with specific parameters (explanation in the [Pocket Docs](http://getpocket.com/developer/docs/v3/retrieve)):
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
List<PocketItem> items = await _client.Get(
|
|
||||||
State? state = null,
|
|
||||||
bool? favorite = null,
|
|
||||||
string tag = null,
|
|
||||||
ContentType? contentType = null,
|
|
||||||
Sort? sort = null,
|
|
||||||
string search = null,
|
|
||||||
string domain = null,
|
|
||||||
DateTime? since = null,
|
|
||||||
int? count = null,
|
|
||||||
int? offset = null
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
It's best to use parameters as _named parameters_, to avoid typing `null` values:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
List<PocketItem> items = await _client.Get(count: 10, offset: 20, sort: Sort.oldest);
|
|
||||||
```
|
|
||||||
|
|
||||||
Get item by ID:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
PocketItem item = await _client.Get(1298198);
|
|
||||||
```
|
|
||||||
|
|
||||||
Find items by a tag:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
List<PocketItem> items = await _client.SearchByTag("tutorial");
|
|
||||||
```
|
|
||||||
|
|
||||||
Find items by a search string.
|
|
||||||
<br>PocketSharp uses an internal search, which is significantly faster than the Search API by Pocket.
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
List<PocketItem> items = await _client.Search("css");
|
|
||||||
```
|
|
||||||
|
|
||||||
Find items by a search string by already available items:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
List<PocketItem> items = await _client.Search(myPocketItemList, "css");
|
|
||||||
```
|
|
||||||
|
|
||||||
Get all tags:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
List<PocketTag> items = await _client.GetTags();
|
|
||||||
```
|
|
||||||
|
|
||||||
Get a filtered list:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
List<PocketItem> items = await _client.Get(RetrieveFilter.Favorite);
|
|
||||||
// returns favorites only
|
|
||||||
```
|
|
||||||
|
|
||||||
The RetrieveFilter Enum is specified as follows:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
enum RetrieveFilter { All, Unread, Archive, Favorite, Article, Video, Image }
|
|
||||||
```
|
|
||||||
|
|
||||||
## Add
|
|
||||||
|
|
||||||
Adds a new item to your pocket list.
|
|
||||||
Accepts four parameters, with `uri` being required.
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
Task<PocketItem> Add(Uri uri, string[] tags = null, string title = null, string tweetID = null)
|
|
||||||
```
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
PocketItem newItem = await _client.Add(
|
|
||||||
new Uri("http://www.neowin.net/news/full-build-2013-conference-sessions-listing-revealed"),
|
|
||||||
new string[] { "microsoft", "neowin", "build" }
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
## Modify
|
|
||||||
|
|
||||||
All Modify methods accept either the itemID (as int) or a `PocketItem` as parameter.
|
|
||||||
|
|
||||||
Archive the specified item:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
bool isSuccess = await _client.Archive(myPocketItem);
|
|
||||||
```
|
|
||||||
|
|
||||||
Un-archive the specified item:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
bool isSuccess = await _client.Unarchive(myPocketItem);
|
|
||||||
```
|
|
||||||
|
|
||||||
Favorites the specified item:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
bool isSuccess = await _client.Favorite(myPocketItem);
|
|
||||||
```
|
|
||||||
|
|
||||||
Un-favorites the specified item:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
bool isSuccess = await _client.Unfavorite(myPocketItem);
|
|
||||||
```
|
|
||||||
|
|
||||||
Deletes the specified item:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
bool isSuccess = await _client.Delete(myPocketItem);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Modify tags
|
|
||||||
|
|
||||||
Add tags to the specified item:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
bool isSuccess = await _client.AddTags(myPocketItem, new string[] { "css", "2013" });
|
|
||||||
```
|
|
||||||
|
|
||||||
Remove tags from the specified item:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
bool isSuccess = await _client.RemoveTags(myPocketItem, new string[] { "css", "2013" });
|
|
||||||
```
|
|
||||||
|
|
||||||
Remove all tags from the specified item:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
bool isSuccess = await _client.RemoveTags(myPocketItem);
|
|
||||||
```
|
|
||||||
|
|
||||||
Replaces all existing tags with new ones for the specified item:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
bool isSuccess = await _client.ReplaceTags(myPocketItem, new string[] { "css", "2013" });
|
|
||||||
```
|
|
||||||
|
|
||||||
Renames a tag for the specified item:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
bool isSuccess = await _client.RenameTag(myPocketItem, "oldTagName", "newTagName");
|
|
||||||
```
|
|
||||||
|
|
||||||
## Statistics
|
|
||||||
|
|
||||||
The Pocket API supports retrieval of a simple statistics object.
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
PocketStatistics statistics = await client.Statistics();
|
|
||||||
// PocketStatistics: [CountAll], [CountRead], [CountUnread]
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Release History
|
|
||||||
|
|
||||||
- **1.5.1** (2013-09-30) `RetrieveFilter.All` didn't work; improve search speed
|
## Supported platforms
|
||||||
- **1.5.0** (2013-09-28) add statistics and registration API
|
|
||||||
- **1.4.0** (2013-09-21) rename `Retrieve` to `Get` + update IntelliSense documentation + add `GetTags` method
|
PocketSharp is a **Portable Class Library** (since 1.0.0), therefore it's compatible with multiple platforms:
|
||||||
- **1.3.0** (2013-09-19) get Item by ID + tag modification bugfixes
|
|
||||||
- **1.2.1** (2013-09-18) correct parameter conversion for DateTime and Boolean
|
- **.NET** >= 4.5 (including WPF)
|
||||||
- **1.2.0** (2013-09-17) simplified retrieve methods
|
- **Silverlight** >= 4
|
||||||
- **1.1.0** (2013-09-17) fix modification requests
|
- **Windows Phone** >= 7.5
|
||||||
- **1.0.0** (2013-09-15) convert to PCL & implement async
|
- **Windows Store**
|
||||||
- **0.3.2** (2013-08-16) tag modification fixed and full retrieval of items for Retrieve method
|
|
||||||
- **0.3.1** (2013-07-07) authentication fixes
|
You can find examples for Silverlight 5, WP8 and WPF in the `PocketSharp.Examples` ([@github](https://github.com/ceee/PocketSharp/tree/master/PocketSharp.Examples)) folder.
|
||||||
- **0.3.0** (2013-07-02) update authentication process
|
|
||||||
- **0.2.0** (2013-06-27) add, modify item & modify tags
|
## What's next?
|
||||||
- **0.1.0** (2013-06-26) authentication & retrieve functionality
|
|
||||||
|
- `cancellationToken` support for all methods
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
- [Microsoft.Bcl.Async](https://www.nuget.org/packages/Microsoft.Bcl.Async/)
|
- [Microsoft.Bcl.Async](https://www.nuget.org/packages/Microsoft.Bcl.Async/)
|
||||||
- [Microsoft.Net.Http](https://www.nuget.org/packages/Microsoft.Net.Http/)
|
- [Microsoft.Net.Http](https://www.nuget.org/packages/Microsoft.Net.Http/)
|
||||||
- [Newtonsoft.Json](https://www.nuget.org/packages/Newtonsoft.Json/)
|
- [Newtonsoft.Json](https://www.nuget.org/packages/Newtonsoft.Json/)
|
||||||
|
- [PropertyChanged.Fody](https://github.com/Fody/PropertyChanged)
|
||||||
|
|
||||||
|
## Forked Dependencies
|
||||||
|
|
||||||
|
- [NReadability](https://github.com/marek-stoj/NReadability) - converted to a PCL with minor adaptations
|
||||||
|
- [SgmlReader](https://github.com/MindTouch/SGMLReader) - converted to a PCL
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
| [](http://twitter.com/artistandsocial "Follow @artistandsocial on Twitter") |
|
| [](https://github.com/ceee "Tobias Klika") | [](https://github.com/ScottIsAFool "Scott Lovegrove") |
|
||||||
|---|
|
|---|---|
|
||||||
| [Tobias Klika @ceee](https://github.com/ceee) |
|
| [ceee](https://github.com/ceee) | [ScottIsAFool](https://github.com/ScottIsAFool) |
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
Reference in New Issue
Block a user