using Json.NET to parse the user timeline

cat-town
Dan Buch 13 years ago
parent 28b9876dc9
commit 15c0345c79

1
.gitignore vendored

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

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

@ -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>

Loading…
Cancel
Save