我正在尝试解析 Twitter 时间线,但出现错误:远程服务器返回错误:NotFound。
这是代码:
private void GetUserTimeLine(string userName)
{
WebClient wcTwitterTimeline = new WebClient();
wcTwitterTimeline.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wcTwitterTimeline_DownloadStringCompleted);
wcTwitterTimeline.DownloadStringAsync(new System.Uri("http://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" + userName));
}
void wcTwitterTimeline_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
List<RootObject> tweets = JsonConvert.DeserializeObject<List<RootObject>>(e.Result);
this.listboxMyTimeline.ItemsSource = tweets;
Dispatcher.BeginInvoke(() =>
{
listboxMyTimeline.Visibility = Visibility.Visible;
txtBoxNewTweet.Visibility = Visibility.Visible;
btnPostTweet.Visibility = Visibility.Visible;
});
}
错误从这里开始:
List<RootObject> tweets = JsonConvert.DeserializeObject<List<RootObject>>(e.Result);