我想使用
Stack Exchange API
Stack Exchange API的Stack Overflow获得最新的问题.
我采取了示例代码,并试图运行它,但是当它从Stack Exchange网站返回数据时它挂起.
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
我究竟做错了什么?
我也看到我可以register my application获得一个API密钥.但是,这不是必须首先运行,是吗?
编辑
如果我删除行
o.FromDate = DateTime.Now.AddMinutes(-10.0); o.ToDate = DateTime.Now;
它工作并返回所有问题.另外如果我添加行
o.Max = 50;
相反,那么它也不起作用.
编辑2
现在它的工作 – 重新启动我的电脑.
最后我用那个代码
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);
和
o.Max
期待Unix大纪元时间,而不是一些最大的帖子.