解析Twitter时间线json Windows Phone

时间:2013-06-16 10:09:27

标签: json twitter windows-phone

我正在尝试解析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);

1 个答案:

答案 0 :(得分:0)

404 Not Found可能是因为您的URL方案是http,应该是https。解决此问题后,您的下一个错误可能是401 Unauthorized,因为Twitter API v1.1需要OAuth身份验证。您可能需要查看Twitter API FAQ和参考文档以获取更多详细信息。