michidk / TwitchCSharp

Twitch C# Wrapper for the Twitch v3 REST API
Apache License 2.0
43 stars 12 forks source link

Bug in TwitchHelper #3

Closed jgoyvaerts closed 9 years ago

jgoyvaerts commented 9 years ago

On https://github.com/michidk/TwitchCSharp/blob/master/TwitchCSharp/Helpers/TwitchHelper.cs#L14 there is a bug, instead of

request.AddParameter("offset", pagingInfo.Page - 1);

it should be

request.AddParameter("offset", pagingInfo.Skip);
michidk commented 9 years ago

Im not sure about it. The paging code is very old. Did you test that?

jgoyvaerts commented 9 years ago

You can see it when you do a request to Twitch directly, when you look at the "next" link:

https://api.twitch.tv/kraken/streams?game=League%20Of%20Legends&limit=5&offset=0

If you would increase the Page by 1, your code would generate:

https://api.twitch.tv/kraken/streams?game=League%20Of%20Legends&limit=5&offset=1

But if you look at the result from the first call, it has a property "next" which is:

https://api.twitch.tv/kraken/streams?game=League+Of+Legends&limit=5&offset=5

Edit: It's the same with any other pagination like MySQL, as explained here: http://www.petefreitag.com/item/451.cfm

michidk commented 9 years ago

Yeah, thanks for the explanation and the bug report! I will fix this in a few seconds.