using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Syndication;
using System.Xml.Serialization;
using Microsoft.Http;

namespace TwitterClient
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Recent tweets about TechedME:\n*************************************************\n");
            SearchTwitter();
            Console.WriteLine("Twitter public timeline:\n*************************************************\n");
            GetPublicTimeline();            
        }

        private static void SearchTwitter()
        {
            HttpClient http = new HttpClient(
                "http://search.twitter.com");
            HttpResponseMessage resp = http.Get("search.atom?q=techedme");
            SyndicationFeed feed = resp.Content.ReadAsSyndicationFeed();
            foreach (SyndicationItem si in feed.Items)
                Console.WriteLine("{0}: {1}\n",
                    si.Authors.First().Name,
                    si.Title.Text);
        }

        private static void GetPublicTimeline()
        {
            HttpClient http = new HttpClient(
                "http://api.twitter.com/1/statuses/");
            HttpResponseMessage resp = http.Get("public_timeline.xml");
            statuses statuses = resp.Content.ReadAsXmlSerializable<statuses>();
            foreach (statusesStatus ss in statuses.status)
                Console.WriteLine("{0}: {1}\n",
                    ss.user.name,
                    ss.text);
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.4927")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
    [System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
    public partial class statuses
    {

        private statusesStatus[] statusField;

        private string typeField;

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("status")]
        public statusesStatus[] status
        {
            get
            {
                return this.statusField;
            }
            set
            {
                this.statusField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute()]
        public string type
        {
            get
            {
                return this.typeField;
            }
            set
            {
                this.typeField = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.4927")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
    public partial class statusesStatus
    {

        private string created_atField;

        private ulong idField;

        private string textField;

        private string sourceField;

        private bool truncatedField;

        private string in_reply_to_status_idField;

        private string in_reply_to_user_idField;

        private bool favoritedField;

        private string in_reply_to_screen_nameField;

        private statusesStatusRetweeted_status retweeted_statusField;

        private statusesStatusUser userField;

        private statusesStatusGeo geoField;

        private object contributorsField;

        /// <remarks/>
        public string created_at
        {
            get
            {
                return this.created_atField;
            }
            set
            {
                this.created_atField = value;
            }
        }

        /// <remarks/>
        public ulong id
        {
            get
            {
                return this.idField;
            }
            set
            {
                this.idField = value;
            }
        }

        /// <remarks/>
        public string text
        {
            get
            {
                return this.textField;
            }
            set
            {
                this.textField = value;
            }
        }

        /// <remarks/>
        public string source
        {
            get
            {
                return this.sourceField;
            }
            set
            {
                this.sourceField = value;
            }
        }

        /// <remarks/>
        public bool truncated
        {
            get
            {
                return this.truncatedField;
            }
            set
            {
                this.truncatedField = value;
            }
        }

        /// <remarks/>
        public string in_reply_to_status_id
        {
            get
            {
                return this.in_reply_to_status_idField;
            }
            set
            {
                this.in_reply_to_status_idField = value;
            }
        }

        /// <remarks/>
        public string in_reply_to_user_id
        {
            get
            {
                return this.in_reply_to_user_idField;
            }
            set
            {
                this.in_reply_to_user_idField = value;
            }
        }

        /// <remarks/>
        public bool favorited
        {
            get
            {
                return this.favoritedField;
            }
            set
            {
                this.favoritedField = value;
            }
        }

        /// <remarks/>
        public string in_reply_to_screen_name
        {
            get
            {
                return this.in_reply_to_screen_nameField;
            }
            set
            {
                this.in_reply_to_screen_nameField = value;
            }
        }

        /// <remarks/>
        public statusesStatusRetweeted_status retweeted_status
        {
            get
            {
                return this.retweeted_statusField;
            }
            set
            {
                this.retweeted_statusField = value;
            }
        }

        /// <remarks/>
        public statusesStatusUser user
        {
            get
            {
                return this.userField;
            }
            set
            {
                this.userField = value;
            }
        }

        /// <remarks/>
        public statusesStatusGeo geo
        {
            get
            {
                return this.geoField;
            }
            set
            {
                this.geoField = value;
            }
        }

        /// <remarks/>
        public object contributors
        {
            get
            {
                return this.contributorsField;
            }
            set
            {
                this.contributorsField = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.4927")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
    public partial class statusesStatusRetweeted_status
    {

        private string created_atField;

        private ulong idField;

        private string textField;

        private string sourceField;

        private bool truncatedField;

        private object in_reply_to_status_idField;

        private object in_reply_to_user_idField;

        private bool favoritedField;

        private object in_reply_to_screen_nameField;

        private statusesStatusRetweeted_statusUser userField;

        private object geoField;

        private object contributorsField;

        /// <remarks/>
        public string created_at
        {
            get
            {
                return this.created_atField;
            }
            set
            {
                this.created_atField = value;
            }
        }

        /// <remarks/>
        public ulong id
        {
            get
            {
                return this.idField;
            }
            set
            {
                this.idField = value;
            }
        }

        /// <remarks/>
        public string text
        {
            get
            {
                return this.textField;
            }
            set
            {
                this.textField = value;
            }
        }

        /// <remarks/>
        public string source
        {
            get
            {
                return this.sourceField;
            }
            set
            {
                this.sourceField = value;
            }
        }

        /// <remarks/>
        public bool truncated
        {
            get
            {
                return this.truncatedField;
            }
            set
            {
                this.truncatedField = value;
            }
        }

        /// <remarks/>
        public object in_reply_to_status_id
        {
            get
            {
                return this.in_reply_to_status_idField;
            }
            set
            {
                this.in_reply_to_status_idField = value;
            }
        }

        /// <remarks/>
        public object in_reply_to_user_id
        {
            get
            {
                return this.in_reply_to_user_idField;
            }
            set
            {
                this.in_reply_to_user_idField = value;
            }
        }

        /// <remarks/>
        public bool favorited
        {
            get
            {
                return this.favoritedField;
            }
            set
            {
                this.favoritedField = value;
            }
        }

        /// <remarks/>
        public object in_reply_to_screen_name
        {
            get
            {
                return this.in_reply_to_screen_nameField;
            }
            set
            {
                this.in_reply_to_screen_nameField = value;
            }
        }

        /// <remarks/>
        public statusesStatusRetweeted_statusUser user
        {
            get
            {
                return this.userField;
            }
            set
            {
                this.userField = value;
            }
        }

        /// <remarks/>
        public object geo
        {
            get
            {
                return this.geoField;
            }
            set
            {
                this.geoField = value;
            }
        }

        /// <remarks/>
        public object contributors
        {
            get
            {
                return this.contributorsField;
            }
            set
            {
                this.contributorsField = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.4927")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
    public partial class statusesStatusRetweeted_statusUser
    {

        private long idField;

        private string nameField;

        private string screen_nameField;

        private string locationField;

        private string descriptionField;

        private string profile_image_urlField;

        private string urlField;

        private bool protectedField;

        private long followers_countField;

        private string profile_background_colorField;

        private string profile_text_colorField;

        private string profile_link_colorField;

        private string profile_sidebar_fill_colorField;

        private string profile_sidebar_border_colorField;

        private long friends_countField;

        private string created_atField;

        private byte favourites_countField;

        private short utc_offsetField;

        private string time_zoneField;

        private string profile_background_image_urlField;

        private bool profile_background_tileField;

        private object notificationsField;

        private bool geo_enabledField;

        private bool verifiedField;

        private object followingField;

        private long statuses_countField;

        private string langField;

        private bool contributors_enabledField;

        /// <remarks/>
        public long id
        {
            get
            {
                return this.idField;
            }
            set
            {
                this.idField = value;
            }
        }

        /// <remarks/>
        public string name
        {
            get
            {
                return this.nameField;
            }
            set
            {
                this.nameField = value;
            }
        }

        /// <remarks/>
        public string screen_name
        {
            get
            {
                return this.screen_nameField;
            }
            set
            {
                this.screen_nameField = value;
            }
        }

        /// <remarks/>
        public string location
        {
            get
            {
                return this.locationField;
            }
            set
            {
                this.locationField = value;
            }
        }

        /// <remarks/>
        public string description
        {
            get
            {
                return this.descriptionField;
            }
            set
            {
                this.descriptionField = value;
            }
        }

        /// <remarks/>
        public string profile_image_url
        {
            get
            {
                return this.profile_image_urlField;
            }
            set
            {
                this.profile_image_urlField = value;
            }
        }

        /// <remarks/>
        public string url
        {
            get
            {
                return this.urlField;
            }
            set
            {
                this.urlField = value;
            }
        }

        /// <remarks/>
        public bool @protected
        {
            get
            {
                return this.protectedField;
            }
            set
            {
                this.protectedField = value;
            }
        }

        /// <remarks/>
        public long followers_count
        {
            get
            {
                return this.followers_countField;
            }
            set
            {
                this.followers_countField = value;
            }
        }

        /// <remarks/>
        public string profile_background_color
        {
            get
            {
                return this.profile_background_colorField;
            }
            set
            {
                this.profile_background_colorField = value;
            }
        }

        /// <remarks/>
        public string profile_text_color
        {
            get
            {
                return this.profile_text_colorField;
            }
            set
            {
                this.profile_text_colorField = value;
            }
        }

        /// <remarks/>
        public string profile_link_color
        {
            get
            {
                return this.profile_link_colorField;
            }
            set
            {
                this.profile_link_colorField = value;
            }
        }

        /// <remarks/>
        public string profile_sidebar_fill_color
        {
            get
            {
                return this.profile_sidebar_fill_colorField;
            }
            set
            {
                this.profile_sidebar_fill_colorField = value;
            }
        }

        /// <remarks/>
        public string profile_sidebar_border_color
        {
            get
            {
                return this.profile_sidebar_border_colorField;
            }
            set
            {
                this.profile_sidebar_border_colorField = value;
            }
        }

        /// <remarks/>
        public long friends_count
        {
            get
            {
                return this.friends_countField;
            }
            set
            {
                this.friends_countField = value;
            }
        }

        /// <remarks/>
        public string created_at
        {
            get
            {
                return this.created_atField;
            }
            set
            {
                this.created_atField = value;
            }
        }

        /// <remarks/>
        public byte favourites_count
        {
            get
            {
                return this.favourites_countField;
            }
            set
            {
                this.favourites_countField = value;
            }
        }

        /// <remarks/>
        public short utc_offset
        {
            get
            {
                return this.utc_offsetField;
            }
            set
            {
                this.utc_offsetField = value;
            }
        }

        /// <remarks/>
        public string time_zone
        {
            get
            {
                return this.time_zoneField;
            }
            set
            {
                this.time_zoneField = value;
            }
        }

        /// <remarks/>
        public string profile_background_image_url
        {
            get
            {
                return this.profile_background_image_urlField;
            }
            set
            {
                this.profile_background_image_urlField = value;
            }
        }

        /// <remarks/>
        public bool profile_background_tile
        {
            get
            {
                return this.profile_background_tileField;
            }
            set
            {
                this.profile_background_tileField = value;
            }
        }

        /// <remarks/>
        public object notifications
        {
            get
            {
                return this.notificationsField;
            }
            set
            {
                this.notificationsField = value;
            }
        }

        /// <remarks/>
        public bool geo_enabled
        {
            get
            {
                return this.geo_enabledField;
            }
            set
            {
                this.geo_enabledField = value;
            }
        }

        /// <remarks/>
        public bool verified
        {
            get
            {
                return this.verifiedField;
            }
            set
            {
                this.verifiedField = value;
            }
        }

        /// <remarks/>
        public object following
        {
            get
            {
                return this.followingField;
            }
            set
            {
                this.followingField = value;
            }
        }

        /// <remarks/>
        public long statuses_count
        {
            get
            {
                return this.statuses_countField;
            }
            set
            {
                this.statuses_countField = value;
            }
        }

        /// <remarks/>
        public string lang
        {
            get
            {
                return this.langField;
            }
            set
            {
                this.langField = value;
            }
        }

        /// <remarks/>
        public bool contributors_enabled
        {
            get
            {
                return this.contributors_enabledField;
            }
            set
            {
                this.contributors_enabledField = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.4927")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
    public partial class statusesStatusUser
    {

        private long idField;

        private string nameField;

        private string screen_nameField;

        private string locationField;

        private string descriptionField;

        private string profile_image_urlField;

        private string urlField;

        private bool protectedField;

        private long followers_countField;

        private string profile_background_colorField;

        private string profile_text_colorField;

        private string profile_link_colorField;

        private string profile_sidebar_fill_colorField;

        private string profile_sidebar_border_colorField;

        private long friends_countField;

        private string created_atField;

        private long favourites_countField;

        private string utc_offsetField;

        private string time_zoneField;

        private string profile_background_image_urlField;

        private bool profile_background_tileField;

        private string notificationsField;

        private bool geo_enabledField;

        private bool verifiedField;

        private string followingField;

        private long statuses_countField;

        private string langField;

        private bool contributors_enabledField;

        /// <remarks/>
        public long id
        {
            get
            {
                return this.idField;
            }
            set
            {
                this.idField = value;
            }
        }

        /// <remarks/>
        public string name
        {
            get
            {
                return this.nameField;
            }
            set
            {
                this.nameField = value;
            }
        }

        /// <remarks/>
        public string screen_name
        {
            get
            {
                return this.screen_nameField;
            }
            set
            {
                this.screen_nameField = value;
            }
        }

        /// <remarks/>
        public string location
        {
            get
            {
                return this.locationField;
            }
            set
            {
                this.locationField = value;
            }
        }

        /// <remarks/>
        public string description
        {
            get
            {
                return this.descriptionField;
            }
            set
            {
                this.descriptionField = value;
            }
        }

        /// <remarks/>
        public string profile_image_url
        {
            get
            {
                return this.profile_image_urlField;
            }
            set
            {
                this.profile_image_urlField = value;
            }
        }

        /// <remarks/>
        public string url
        {
            get
            {
                return this.urlField;
            }
            set
            {
                this.urlField = value;
            }
        }

        /// <remarks/>
        public bool @protected
        {
            get
            {
                return this.protectedField;
            }
            set
            {
                this.protectedField = value;
            }
        }

        /// <remarks/>
        public long followers_count
        {
            get
            {
                return this.followers_countField;
            }
            set
            {
                this.followers_countField = value;
            }
        }

        /// <remarks/>
        public string profile_background_color
        {
            get
            {
                return this.profile_background_colorField;
            }
            set
            {
                this.profile_background_colorField = value;
            }
        }

        /// <remarks/>
        public string profile_text_color
        {
            get
            {
                return this.profile_text_colorField;
            }
            set
            {
                this.profile_text_colorField = value;
            }
        }

        /// <remarks/>
        public string profile_link_color
        {
            get
            {
                return this.profile_link_colorField;
            }
            set
            {
                this.profile_link_colorField = value;
            }
        }

        /// <remarks/>
        public string profile_sidebar_fill_color
        {
            get
            {
                return this.profile_sidebar_fill_colorField;
            }
            set
            {
                this.profile_sidebar_fill_colorField = value;
            }
        }

        /// <remarks/>
        public string profile_sidebar_border_color
        {
            get
            {
                return this.profile_sidebar_border_colorField;
            }
            set
            {
                this.profile_sidebar_border_colorField = value;
            }
        }

        /// <remarks/>
        public long friends_count
        {
            get
            {
                return this.friends_countField;
            }
            set
            {
                this.friends_countField = value;
            }
        }

        /// <remarks/>
        public string created_at
        {
            get
            {
                return this.created_atField;
            }
            set
            {
                this.created_atField = value;
            }
        }

        /// <remarks/>
        public long favourites_count
        {
            get
            {
                return this.favourites_countField;
            }
            set
            {
                this.favourites_countField = value;
            }
        }

        /// <remarks/>
        public string utc_offset
        {
            get
            {
                return this.utc_offsetField;
            }
            set
            {
                this.utc_offsetField = value;
            }
        }

        /// <remarks/>
        public string time_zone
        {
            get
            {
                return this.time_zoneField;
            }
            set
            {
                this.time_zoneField = value;
            }
        }

        /// <remarks/>
        public string profile_background_image_url
        {
            get
            {
                return this.profile_background_image_urlField;
            }
            set
            {
                this.profile_background_image_urlField = value;
            }
        }

        /// <remarks/>
        public bool profile_background_tile
        {
            get
            {
                return this.profile_background_tileField;
            }
            set
            {
                this.profile_background_tileField = value;
            }
        }

        /// <remarks/>
        public string notifications
        {
            get
            {
                return this.notificationsField;
            }
            set
            {
                this.notificationsField = value;
            }
        }

        /// <remarks/>
        public bool geo_enabled
        {
            get
            {
                return this.geo_enabledField;
            }
            set
            {
                this.geo_enabledField = value;
            }
        }

        /// <remarks/>
        public bool verified
        {
            get
            {
                return this.verifiedField;
            }
            set
            {
                this.verifiedField = value;
            }
        }

        /// <remarks/>
        public string following
        {
            get
            {
                return this.followingField;
            }
            set
            {
                this.followingField = value;
            }
        }

        /// <remarks/>
        public long statuses_count
        {
            get
            {
                return this.statuses_countField;
            }
            set
            {
                this.statuses_countField = value;
            }
        }

        /// <remarks/>
        public string lang
        {
            get
            {
                return this.langField;
            }
            set
            {
                this.langField = value;
            }
        }

        /// <remarks/>
        public bool contributors_enabled
        {
            get
            {
                return this.contributors_enabledField;
            }
            set
            {
                this.contributors_enabledField = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.4927")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
    public partial class statusesStatusGeo
    {

        private string pointField;

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Namespace = "http://www.georss.org/georss")]
        public string point
        {
            get
            {
                return this.pointField;
            }
            set
            {
                this.pointField = value;
            }
        }
    }

}
