Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Stack Overflow questions with Stacky API

I want to get the most current questions from Stack Overflow using the Stacky C# library for the Stack Exchange API.

I took the example code and tried to run it but it hangs when it comes to returning data from the Stack Exchange website.

StackyClient client = new StackyClient("0.9", "", Sites.StackOverflow, 
            new UrlClient(), new JsonProtocol());

var o = new QuestionOptions();
o.FromDate = DateTime.Now.AddMinutes(-10.0);
o.ToDate = DateTime.Now;
o.IncludeAnswers = false;
o.IncludeBody = false;
o.IncludeComments = false;
o.SortBy = QuestionSort.Creation;
o.SortDirection = SortDirection.Descending;

IPagedList<Question> l = client.GetQuestions(o); <--- program hangs here 4ever

What am I doing wrong?

I also saw that I can register my application to get an API Key. But that is not necessary to make it run in the first place, is it?

Edit

If I remove the lines

o.FromDate = DateTime.Now.AddMinutes(-10.0);
o.ToDate = DateTime.Now;

it works and returns all questions. Also if I add the line

o.Max = 50;

instead, then it does not work either.

Edit 2

Now it works - rebooted my computer.
BTW I used that code in the end

var o = new QuestionOptions();
o.FromDate = DateTime.UtcNow.AddMinutes(-20);
o.IncludeAnswers = false;
o.IncludeBody = false;
o.IncludeComments = false;
o.SortBy = QuestionSort.Creation;
o.SortDirection = SortDirection.Descending;

IPagedList<Question> l = client.GetQuestions(o);

And

o.Max

expects an Unix Epoch time, not a number of maximum posts.

like image 692
juergen d Avatar asked Apr 24 '13 14:04

juergen d


1 Answers

Try changing the version specified in the StackyClient constructor from "0.9" to "1.1". I get a JSON parse error on the client.GetQuestions(o) line when the version is "0.9", but it runs fine with "1.1".

like image 140
WarrenG Avatar answered Oct 26 '22 18:10

WarrenG