using Json.NET to parse the user timeline

This commit is contained in:
Dan Buch 2011-07-31 22:22:32 -04:00
parent 28b9876dc9
commit 15c0345c79
3 changed files with 9 additions and 8 deletions

1
.gitignore vendored
View File

@ -6,4 +6,5 @@
*.dll
*.pdb
TwitterPractice/TwitterPractice/bin
TwitterPractice/bin/EntityFramework.xml

View File

@ -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));
}
}
}

View File

@ -112,7 +112,9 @@
<Content Include="Scripts\jquery.validate.min.js" />
<Content Include="Scripts\modernizr-1.7.js" />
<Content Include="Scripts\modernizr-1.7.min.js" />
<Content Include="Web.config" />
<Content Include="Web.config">
<SubType>Designer</SubType>
</Content>
<Content Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</Content>