获取叽叽喳喳公开时间表,JSON + C#,没有第三方库 [英] Get twitter public timeline, json+C#, no 3rd party libraries

查看:195
本文介绍了获取叽叽喳喳公开时间表,JSON + C#,没有第三方库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#和JSON初学者,我只在Java编码(基本的东西,如读/写文件,包含HashMap等,没有网络的发展无论如何,初学编程的)

I'm a beginner in C# and JSON, I've only been coding in Java (Basic stuff like reading/writing files, hashmaps, etc., no web development whatsoever, beginner programmer)

我是一名学生,一直负责在C#这与Twitter进行交互codeA控制台应用程序。现在,我坚持了极端的基础知识。我试图让使用JSON和C#的公开时间表鸣叫。我已经成功地通过使用Twitterizer的这样做,但我只发现最近,我不能使用第三方库(比NewtonSoft.JSON.dll等),并且必须code一切从头开始。我真的AP preciate,如果有人可以给我提供样品code,这是否和preferably打印出最新的鸣叫和公众的时间表对应的用户,这样我就可以大致知道怎么怎么数据被读出和使用。

I'm a student and have been tasked to code a console app in C# which interacts with twitter. For now, I'm stuck with extreme basics. I'm trying to get tweets in a public timeline using JSON and C#. I've been successful with doing this through the use of Twitterizer, but I only found out recently that I cannot use 3rd-party libraries (other than NewtonSoft.JSON.dll), and must code everything from scratch. I would really appreciate it if someone could provide me with sample code that does this and preferably prints out the latest tweet and its corresponding user from the public timeline, so that I can roughly know how how data is read and used.

我的JSON和C#的理解是非常有限的,但是这是我知道我应该做的启动:

My understanding of JSON and C# is extremely limited, but this is what I know I'm supposed to do for a start:

  1. 的WebRequest W1 = WebRequest.Create(http://api.twitter.com/1/statuses/public_timeline.json);
  2. w1.getResponse();
  3. 在我不知道该怎么办/如何解析JSON文件

感谢您

推荐答案

这可以是一个出发点。 (您也可以使用的Json查看器让你JSON的格式化版本)

This can be a starting point. (You can also use Json Viewer to get a formatted version of your json)

using (WebClient webClient = new WebClient())
{
    string url = "http://api.twitter.com/1/statuses/public_timeline.json";
    dynamic json = JsonConvert.DeserializeObject(webClient.DownloadString(url));

    foreach (var item in json)
    {
        Console.WriteLine("{0} {1}", item.user.id, item.user.screen_name);
    }
}

PS:JsonConvert是NewtonSoft库的一部分

PS: JsonConvert is a part of NewtonSoft library

这篇关于获取叽叽喳喳公开时间表,JSON + C#,没有第三方库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆