From 15c0345c792a80c9f4a88fa19b7ec3a3e2596fdc Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sun, 31 Jul 2011 22:22:32 -0400 Subject: [PATCH] using Json.NET to parse the user timeline --- .gitignore | 1 + .../TwitterPractice/Controllers/HomeController.cs | 12 +++++------- .../TwitterPractice/TwitterPractice.csproj | 4 +++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index b68fdbc..0a224c5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ *.dll *.pdb +TwitterPractice/TwitterPractice/bin TwitterPractice/bin/EntityFramework.xml diff --git a/TwitterPractice/TwitterPractice/Controllers/HomeController.cs b/TwitterPractice/TwitterPractice/Controllers/HomeController.cs index 685fef1..0f0a034 100644 --- a/TwitterPractice/TwitterPractice/Controllers/HomeController.cs +++ b/TwitterPractice/TwitterPractice/Controllers/HomeController.cs @@ -1,11 +1,9 @@ using System; -using System.Collections.Generic; -using System.Collections.Specialized; using System.Configuration; -using System.Linq; using System.Net; -using System.Web; using System.Web.Mvc; +using Newtonsoft.Json.Linq; + namespace TwitterPractice.Controllers { @@ -29,16 +27,16 @@ namespace TwitterPractice.Controllers { username = "meatballhat"; } - ViewBag.UserTimeline = GetTwitterStream(username).Replace("\",", "\",\n"); + ViewBag.UserTimeline = GetTwitterStream(username); ViewBag.Username = username; return View(); } - private string GetTwitterStream(string username="meatballhat") + private JArray GetTwitterStream(string username="meatballhat") { string requestUrl = String.Format(requestTemplate, username); WebClient req = new WebClient(); - return req.DownloadString(requestUrl); + return JArray.Parse(req.DownloadString(requestUrl)); } } } diff --git a/TwitterPractice/TwitterPractice/TwitterPractice.csproj b/TwitterPractice/TwitterPractice/TwitterPractice.csproj index fdfd32d..47cbf53 100644 --- a/TwitterPractice/TwitterPractice/TwitterPractice.csproj +++ b/TwitterPractice/TwitterPractice/TwitterPractice.csproj @@ -112,7 +112,9 @@ - + + Designer + Web.config