Git Product home page Git Product logo

pocketsharp's People

Contributors

ceee avatar felipepessoto avatar scottisafool avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pocketsharp's Issues

PocketReader and encoding

Does the PocketReader detect the encoding of the article? I works fine for me for articles in english or UTF8, but when trying to "read" an article that is in another encoding (e.g: http://navolnenoze.cz/blog/vydelky/ in win1250) the read method returns a messed up text.

For example, the h1 tag, I get "Kolik se d� vyd�lat na voln� noze?" instead of "Kolik se dá vydělat na volné noze?"

version 5.0 add problem

PocketClient.Add method in version 5.0 takes a very long time to complete and it was not the case in 4.2

Create .NET Framework version

Cannot reference version 5.0.0 in WinForms because there is no .NET Framework version. It would be helpful otherwise I have to override all of the PocketSharp methods & objects in a separate .NET Standard class.

Feature Request: JSON on Returned Models

I would like to have the JSON the model was deserialized from as a string property.

Uses of this would be a few fold, but the main one for me is to be able to get future properties, so if something isn't handled by the lib during deserialization it is still on the JSON so I can get it.

I can implement as well, but want to know if you would be up for a pull request with this feature.

System.StackOverflowException when testing PocketItem for null

I upgraded from 4.0.0.0 to 4.1.4.0 and I am getting System.StackOverflowException in PocketSharp.dll when testing a PocketItem for null.

The complete flow:

  • I add an article to the Pocket account
  • I get the change using _client.Get(null, null, null, null, null, null, null, lastRun, 20, offset), one item us returned
  • then I check the one item for null, just to be sure (in a loop going through all the returned changes I have if (item == null) continue;
  • the app crashes with System.StackOverflowException in PocketSharp.dll

Serialization Problem [InvalidCastException]

I can get PocketItems with no problem.
But when I tried to use Akavache to cache IEnumerable<PocketItem> I get above InvalidCastException !
Also, I have tried to serialize with newtonsoft.json and I got the same exception.

  • MY CODE:
IEnumerable<PocketItem> get = await client.Get(
                           state: state, favorite: favorite,
                           tag: tag, contentType: null,
                           sort: Sort.newest, search: search,
                           domain: null, since: null,
                           count: count, offset: offset);
await Akavache .BlobCache.LocalMachine.InsertObject("key", get);
  • EXCEPTION
{System.InvalidCastException: Unable to cast object of type 'System.Collections.Generic.List`1[PocketSharp.Models.PocketAuthor]' to type 'PocketSharp.Models.PocketItem'.
   at PocketSharp.Models.PocketItem.Equals(Object obj)
   at System.Collections.Generic.ObjectEqualityComparer`1.IndexOf(T[] array, T value, Int32 startIndex, Int32 count)
   at System.Array.IndexOf[T](T[] array, T value, Int32 startIndex, Int32 count)
   at System.Collections.Generic.List`1.IndexOf(T item)
   at System.Collections.Generic.List`1.Contains(T item)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CheckForCircularReference(JsonWriter writer, Object value, JsonProperty property, JsonContract contract, JsonContainerContract containerContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
   at Akavache.Sqlite3.SQLitePersistentBlobCache.SerializeObject[T](T value)
   at Akavache.Sqlite3.SQLitePersistentBlobCache.InsertObject[T](String key, T value, Nullable`1 absoluteExpiration)
   at Akavache.JsonSerializationMixin.InsertObject[T](IBlobCache This, String key, T value, Nullable`1 absoluteExpiration)
   at PocketX.Handlers.PocketHandler.<GetListAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---

Empty callback Url?

Currently, this is how I'm authenticating with PocketSharp:

public static void AuthPocket()
{
    PocketClient = new PocketClient(ConsumerKey);
    PocketClient.CallbackUri = "https://getpocket.com/a/queue/"; //Todo: prevent this from opening
    string requestCode = PocketClient.GetRequestCode().Result;
    Uri authenticationUri = PocketClient.GenerateAuthenticationUri();
    Process.Start(authenticationUri.ToString());

    PocketUser user = null;
    while (true)
    {
        try
        {
            user = PocketClient.GetUser(requestCode).Result;
            break;
        }
        catch { }
        System.Threading.Thread.Sleep(500);
    }

    PocketClient = new PocketClient(ConsumerKey, user.Code);
}

My main problem is that every time this code runs, it opens the callback url in the user's browser. Is there a way I can avoid that? I know I can just save the user.Code in a file somewhere but I want my program to not have to write to any "settings" files

Getting user info after login

I am trying to get the username of the currently logged in user. If I call GetUser() I get

System.NullReferenceException: Call GetRequestCode() first to receive a request_code

if I call GetUser(_requestCode) I get sometimes the same exception and sometimes an exception stating that the request code has already been used.

Remove registration

Have to remove the registration method as Pocket is going to shutdown the API endpoint for it the upcoming weeks.

@ScottIsAFool Do you use it in Squirrel?

Getting Call GetRequestCode() first to receive a request_code

I am trying to implement user authentification. First I create a client

_client = new PocketClient("consumer key",null,"http://www.google.com");      

then I request the request code

_requestCode= await _client.GetRequestCode();

and navigate to the Uri provided by

_client.GenerateAuthenticationUri()

So far so good. I enter my credentials and I am redirected to google.com (my redirect uri). At that moment I call

string accessCode = await _client.GetAccessCode(_requestCode);

and I get "Call GetRequestCode() first to receive a request_code" exception

Null reference when sending actions

I'm getting a null reference from the PocketClient when trying to send actions. Here's my code:

                List<PocketAction> actions = new List<PocketAction>();

                foreach (PocketWP.PocketDataItem item in ToAddData.Items)
                {
                    PocketAction nAction = new PocketAction();
                    nAction.Action = "add";
                    nAction.Uri = new Uri(item.Uri);
                    if (item.TagsArray != null)
                    {
                        nAction.Tags = item.TagsArray;
                    }
                    if (item.Title != null && item.Title != "")
                    {
                        nAction.Title = item.Title;
                    }
                    if (item.TweetId != null)
                    {
                        nAction.TweetID = item.TweetId;
                    }
                    actions.Add(nAction);
                }

                bool success = false;
                try
                {
                    success = await CLIENT.SendActions(actions);
                }
                catch (Exception ex)
                {

                }

The error is thrown in the try/catch block.

   at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
   at Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at PocketSharp.PocketClient.<SendActions>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Pouch.ViewModel.MainViewModel.<AddItemFromPocketWP>d__38.MoveNext()

I've walked through it and the data I'm sending seems to be fine.

Thanks,
Joshua

Expose Since property received from pocket server for Retrieve response.

From pocket documentation in Best practices section.

After retrieving the list, you should store the current time (which is provided along with the list response) and pass that in the next request for the list

I'm trying to save the Since property returned by server, so that next time I can request from that time; But it seems it is not exposed in the PocketClient API (Unless I'm missing something).

I can see the Since property in source code. If this is what the documentation is talking about, please expose it in the API.

It will be very helpful, otherwise we need to rely on our local machine time which is likely to invite time synchronization problems.

If I'm misunderstanding something please correct me.

Thanks in advance.

Getting empty item titles

As of today, I am getting empty titles for PocketItems. I am on version 5.0.0. Not sure if Pocket changed something about the API?

image

Raw Json property on PocketItem

Just updated to NuGet package version 4.1.6.1 and it looks like the Json property off of the PocketItem object was removed. Master branch shows it as still there, but the simple branch shows it as missing.

Is this version from the simple branch? If the change was reverted, can I get an update to the NuGet package with the return of the property?

Getting 'System.InvalidOperationException: Current error context error is different to requested error' when adding an item

I'm getting an exception thrown when calling PocketClient.Add. The item DOES get added to Pocket, but the exception is thrown. I tried de-authorizing the PocketClient & re-authorizing but I'm still getting the exception.

The stack trace and this SO post seem to imply it's something about Newtonsoft trying to get the error context within a JsonConverter called by another JsonConverter.

Code:

try
{
    string youTubeURL = Common.YOUTUBEVIDEOBASEURL + youTubeVideoId;
    await Settings.PocketClient.Add(new Uri(youTubeURL));
}
catch (Exception ex)
{
    Log("Exception thrown when adding to pocket!");
    Common.DumpException(ex);
}

Full exception details:

Current error context error is different to requested error.

    at Newtonsoft.Json.Serialization.JsonSerializerInternalBase.GetErrorContext(Object currentObject, Object member, String path, Exception error)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalBase.IsErrorHandled(Object currentObject, JsonContract contract, Object keyValue, IJsonLineInfo lineInfo, String path, Exception ex)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at PocketSharp.PocketClient.DeserializeJson[T](String json)
   at PocketSharp.PocketClient.<Request>d__79`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PocketSharp.PocketClient.<Add>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at MyApp.Main.<AddYouTubeVideoToPocket>d__15.MoveNext()

Why is ID string?

Why is ID of type string? It looks like int to me. Or is it not guaranteed to be int?

Getting articles changed since some timestamp does not seem to work

I am trying to use the Get method to just get changes instead of the whole list.

If I use the "since" parameter, it does not seem to work. I added a few articles to my pocket account, set since to DateTime.Now.AddMinutes(-10) just to be sure and I get back an empty list.

And a related question, how do I get the list of changes (moved, deleted) articles since some timestamp?

Provide sample code for desktop application?

Would you please consider providing some sample code for a desktop application (or am I missing this sample code maybe?). The whole OAuth2, which always gets my head spinning because it's NOT "easy to implement" (let alone implement correctly), requiring a callback_uri doesn't seem to go hand-in-hand with deskop applications, most probably behind a firewall to complicate things further. I have been googling for "OAuth2 desktop application" etc. and have found some clues but nothing that worked so far. Any help or sample code would be greatly appreciated.

WP7 crash

On WP7 I am gettting this when trying to request the access code for oauth

{"Parse error: Attempt to access the method failed: PocketSharp.Models.RequestCode..ctor()"}

at PocketSharp.PocketClient.b__90[T](Object sender, ErrorEventArgs args)
at Newtonsoft.Json.JsonSerializer.OnError(ErrorEventArgs e)
at Newtonsoft.Json.Serialization.JsonSerializerInternalBase.IsErrorHandled(Object currentObject, JsonContract contract, Object keyValue, IJsonLineInfo lineInfo, String path, Exception ex)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at PocketSharp.PocketClient.d__91`1.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run()
at Microsoft.Runtime.CompilerServices.TaskAwaiter.<>c__DisplayClassa.b__1(Object state)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Delegate.DynamicInvokeOne(Object[] args)
at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)

PocketSharp exception when parsing results

Doing a Get() gives me the following JSON response. PocketSharp is failing to parse this (using latest code, not nuget package). Problem is in the ObjectToListConverter

{"status":1,"complete":1,"list":{"479542191":{"item_id":"479542191","resolved_id":"479542191","given_url":"http://getpocket.com/blog/2013/11/pocket-5-0-introducing-a-smarter-pocket/","given_title":"","favorite":"0","status":"0","time_added":"1384376206","time_updated":"1384456232","time_read":"0","time_favorited":"0","sort_id":0,"resolved_title":"Pocket 5.0: Introducing a Smarter Pocket","resolved_url":"http://getpocket.com/blog/2013/11/pocket-5-0-introducing-a-smarter-pocket/","excerpt":"At Pocket, it\u2019s always been our goal to make saving and consuming content as easy and fast as possible, wherever you are, on any screen. Over 800 million items have been saved to Pocket, with an additional 1.5 million being saved every day from thousands of apps, blogs, and websites.","is_article":"1","is_index":"0","has_video":"0","has_image":"1","word_count":"837","authors":{"13703791":{"item_id":"479542191","author_id":"13703791","name":"November 13th, 2013 \u2022 By Kait","url":""}},"image":{"item_id":"479542191","src":"http://pocket-blog.s3.amazonaws.com/20131113/1_Pocket5_BlogGraphic_Hero.png","width":"0","height":"0"},"images":{"1":{"item_id":"479542191","image_id":"1","src":"http://pocket-blog.s3.amazonaws.com/20131113/1_Pocket5_BlogGraphic_Hero.png","width":"0","height":"0","credit":"","caption":""},"2":{"item_id":"479542191","image_id":"2","src":"http://pocket-blog.s3.amazonaws.com/20131113/2_Pocket5_BlogGraphic_Highlights.png","width":"0","height":"0","credit":"","caption":""},"3":{"item_id":"479542191","image_id":"3","src":"http://pocket-blog.s3.amazonaws.com/20131113/4_Pocket5_Graphics_Dynamic.png","width":"0","height":"0","credit":"","caption":""},"4":{"item_id":"479542191","image_id":"4","src":"http://pocket-blog.s3.amazonaws.com/20131113/4_Pocket5_BlogGraphic_Carousel.png","width":"0","height":"0","credit":"","caption":""},"5":{"item_id":"479542191","image_id":"5","src":"http://pocket-blog.s3.amazonaws.com/20131113/5_Pocket5_BlogGraphic_ListPlusTablet%20%281%29.png","width":"0","height":"0","credit":"","caption":""},"6":{"item_id":"479542191","image_id":"6","src":"http://pocket-blog.s3.amazonaws.com/20131113/5_Pocket5_BlogGraphic_SideNav.png","width":"0","height":"0","credit":"","caption":""}}}},"since":1384800910}

Upgrade library to PCL

Make the library portable as a PCL.
Therefore RestSharp and ServiceStack.Text should better be removed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.