C# 使用特定单词获取推文

C# 使用特定单词获取推文,c#,wpf,twitter,C#,Wpf,Twitter,我想用Windows这个词发一些推特。 C: XAML: 什么问题?什么问题?您需要什么帮助?@GrahamSavage它会抛出一个类型为System.Net.WebException的未处理异常 using System; using System.Net; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

我想用Windows这个词发一些推特。 C:

XAML:


什么问题?

什么问题?您需要什么帮助?@GrahamSavage它会抛出一个类型为System.Net.WebException的未处理异常
using System;
using System.Net;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml.Linq;

namespace WpfApplication1 {

    public partial class MainWindow : Window {

        public MainWindow() {
            InitializeComponent();
        }

        public class Tweet {
            public String Content { get; set; }
            public String Image { get; set; }
        }

        private void Button_Click(object sender, RoutedEventArgs e) {
            Results();
        }

        public static List<Tweet> Results() {
            using (WebClient wc = new WebClient()) {
                WebClient client = new WebClient();
                XDocument doc = XDocument.Load(string.Format("https://api.twitter.com/1.1/search/tweets.json?q=%23windows"));
                XNamespace ns = "http://www.w3.org/2005/Atom";
                List<Tweet> tweets = (from item in doc.Descendants(ns + "entry")
                                      select new Tweet {
                                          Content = item.Elements(ns + "content").ToString(),
                                          Image = (from XElement x in item.Descendants(ns + "link")
                                                   where x.Attribute("type").Value == "image/png"
                                                   select x.Attribute("href").Value).First()
                                      }).ToList();
                return tweets;
            }
        }

    }

}
<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <StackPanel>
            <Button
                Content="Refresh"
                Click="Button_Click"></Button>
            <ListBox x:Name="list"></ListBox>
        </StackPanel>
    </Grid>
</Window>