public string getTwitter(string user)
        {
            try
            {
                SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
                SqlDataReader dr;
                SqlCommand    cmd = new SqlCommand();
                cmd.CommandText = "select * from tbl_ext_creds_twitter (nolock) where userid='" + user + "'";
                cmd.Connection  = conn;
                conn.Open();

                if (conn.State == ConnectionState.Open)
                {
                    dr = cmd.ExecuteReader();
                    dr.Read();
                    if (dr.HasRows)
                    {
                        //Session["twtoken"] = dr[1].ToString();
                        //Session["twsecret"] = dr[2].ToString();
                        //Session["twscreenname"] = dr[4].ToString();
                        //Session["twuserid"] = dr[3].ToString();

                        var service = new TwitterService(ConfigurationManager.AppSettings["twitter.appkey"].ToString(), ConfigurationManager.AppSettings["twitter.appsecret"].ToString());
                        //service.AuthenticateWith(ConfigurationManager.AppSettings["twitter.accesstoken"].ToString(), ConfigurationManager.AppSettings["twitter.accesstokensecret"].ToString());
                        service.AuthenticateWith(dr[1].ToString(), dr[2].ToString());
                        ListTweetsOnUserTimelineOptions opt = new ListTweetsOnUserTimelineOptions {
                            ScreenName = dr[4].ToString(), Count = 5
                        };
                        //IEnumerable<TwitterStatus> tweets = service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { ScreenName = Session["twscreenname"].ToString(), Count = 5 });
                        IEnumerable <TwitterStatus> tweets = service.ListTweetsOnUserTimeline(opt);
                        if (tweets != null)
                        {
                            //var t = (TwitterStatus)JsonConvert.DeserializeObject(tweets, typeof(TwitterStatus));


                            foreach (var tweet in tweets)
                            {
                                MPtweets aTweet = new MPtweets();
                                aTweet.profileImageUrl = tweet.Author.ProfileImageUrl;
                                aTweet.ScreenName      = tweet.Author.ScreenName;
                                aTweet.CreatedDate     = tweet.CreatedDate.ToString();
                                aTweet.Text            = tweet.Text;
                                mpt.Add(aTweet);
                                //twitter.InnerHtml = twitter.InnerHtml + "<li> <p> <table><tr><td><img alt=\"\" src=\"" + tweet.Author.ProfileImageUrl + "\" /></td><td> <table> <tr> <td> " + tweet.Author.ScreenName + " </td> </tr> <tr><td>" + tweet.CreatedDate.ToString("MM/dd/yyyy") + " </td> </tr></table> </td></tr></table> </p></li></br>";
                                //twitter.InnerHtml = twitter.InnerHtml + "<li> <p>" + tweet.Text + "</p></li></br>";
                            }

                            twdata = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(mpt);
                        }
                    }
                    dr.Close();
                }
                conn.Close();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
            return(twdata);
        }
        public string getTwitter(string user)
        {
            try
            {
                SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
                SqlDataReader dr;
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "select * from tbl_ext_creds_twitter (nolock) where userid='" + user + "'";
                cmd.Connection = conn;
                conn.Open();

                if (conn.State == ConnectionState.Open)
                {
                    dr = cmd.ExecuteReader();
                    dr.Read();
                    if (dr.HasRows)
                    {
                        //Session["twtoken"] = dr[1].ToString();
                        //Session["twsecret"] = dr[2].ToString();
                        //Session["twscreenname"] = dr[4].ToString();
                        //Session["twuserid"] = dr[3].ToString();

                        var service = new TwitterService(ConfigurationManager.AppSettings["twitter.appkey"].ToString(), ConfigurationManager.AppSettings["twitter.appsecret"].ToString());
                        //service.AuthenticateWith(ConfigurationManager.AppSettings["twitter.accesstoken"].ToString(), ConfigurationManager.AppSettings["twitter.accesstokensecret"].ToString());
                        service.AuthenticateWith(dr[1].ToString(), dr[2].ToString());
                        ListTweetsOnUserTimelineOptions opt = new ListTweetsOnUserTimelineOptions { ScreenName = dr[4].ToString(), Count = 5 };
                        //IEnumerable<TwitterStatus> tweets = service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { ScreenName = Session["twscreenname"].ToString(), Count = 5 });
                        IEnumerable<TwitterStatus> tweets = service.ListTweetsOnUserTimeline(opt);
                        if (tweets != null)
                        {
                            //var t = (TwitterStatus)JsonConvert.DeserializeObject(tweets, typeof(TwitterStatus));

                            foreach (var tweet in tweets)
                            {
                                MPtweets aTweet = new MPtweets();
                                aTweet.profileImageUrl = tweet.Author.ProfileImageUrl;
                                aTweet.ScreenName = tweet.Author.ScreenName;
                                aTweet.CreatedDate = tweet.CreatedDate.ToString();
                                aTweet.Text = tweet.Text;
                                mpt.Add(aTweet);
                                //twitter.InnerHtml = twitter.InnerHtml + "<li> <p> <table><tr><td><img alt=\"\" src=\"" + tweet.Author.ProfileImageUrl + "\" /></td><td> <table> <tr> <td> " + tweet.Author.ScreenName + " </td> </tr> <tr><td>" + tweet.CreatedDate.ToString("MM/dd/yyyy") + " </td> </tr></table> </td></tr></table> </p></li></br>";
                                //twitter.InnerHtml = twitter.InnerHtml + "<li> <p>" + tweet.Text + "</p></li></br>";
                            }

                            twdata = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(mpt);

                        }

                    }
                    dr.Close();
                }
                conn.Close();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
            return twdata;
        }