Example #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Gets the last friends tweets. </summary>
        ///
        /// <remarks>   Olivier Gagnon, 2009-11-09. </remarks>
        ///
        /// <param name="sender">   Source of the event. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public static void GetLastFriendsTweets(object sender)
        {
            lock (locker)
            {
                var tw = new TweetWin("Last Tweets from Friends");
                int numberOfTweets = 25;
                var logininfo = (LoginInfo)sender;
                AccountInfo ac = AccountInfo.GetTwitterAccountInfo(logininfo.Username);

                // Set background image from twitter
                var uri = new Uri(ac.Background);
                Stream s = WebRequest.Create(uri)
                    .GetResponse().GetResponseStream();
                Image backimg = Image.FromStream(s);

                tw.TweetPanel.BackgroundImage = backimg;
                tw.TweetPanel.BackColor = Color.Transparent;

                FluentTwitter.CreateRequest()
                    .AuthenticateAs(logininfo.Username, logininfo.Password)
                    .Account().GetRateLimitStatus().AsJson()
                    .CallbackTo((f, e) => OnRequestReturn(tw, e))
                    .RepeatEvery(1.Minute()).RequestAsync();

                // Create Tweets and show
                string twitter = FluentTwitter.CreateRequest()
                    .AuthenticateWith(logininfo.TcInfo.ConsumerKey, logininfo.TcInfo.ConsumerSecret,
                                      logininfo.Authtoken.Token, logininfo.Authtoken.TokenSecret)
                    .Statuses().OnFriendsTimeline().Take(numberOfTweets).AsJson()
                    .Request();

                IEnumerable<TwitterStatus> response = twitter.AsStatuses();
                int i = 0;
                foreach (TwitterStatus ts in response)
                {
                    var tweet = new Tweet();
                    tweet.Location = new Point(0, (0 + i * 100));
                    tweet.TweetText.Text = ts.Text;
                    tweet.TweetImage.ImageLocation = ts.User.ProfileImageUrl;
                    tweet.lluser.Text = ts.User.ScreenName;
                    tweet.lvia.Text = "via " + Utilities.StripHtml(ts.Source);
                    tweet.ltimeago.Text = ts.CreatedDate.ToRelativeTime();
                    tw.TweetPanel.Controls.Add(tweet);
                    i++;
                }
                Application.Run(tw);
            }
        }
Example #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Send tweet. </summary>
        ///
        /// <remarks>   Olivier Gagnon, 2009-11-11. </remarks>
        ///
        /// <param name="currenttweet"> The currenttweet control. </param>
        /// <param name="logininfo">    The login informations. </param>
        /// <param name="tweetbox">     The tweetbox control. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public static void SendTweet(Tweet currenttweet, LoginInfo logininfo, TextBox tweetbox)
        {
            try
            {
                IFluentTwitter tf = FluentTwitter.CreateRequest(logininfo.TcInfo);

                string request =
                    tf.AuthenticateWith(logininfo.Authtoken.Token, logininfo.Authtoken.TokenSecret).Statuses().Update(tweetbox.Text).AsJson().
                        Request();

                RefreshStatus(currenttweet, logininfo);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error sending tweet", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
            }
        }
Example #3
0
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>   Refresh status. </summary>
 ///
 /// <remarks>   Olivier Gagnon, 2009-11-10. </remarks>
 ///
 /// <param name="currenttweet"> The currenttweet. </param>
 /// <param name="logininfo">    The login informations. </param>
 ///
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 public static void RefreshStatus(Tweet currenttweet, LoginInfo logininfo)
 {
     try
     {
         currenttweet.TweetText.Text = "Retrieving status.......";
         currenttweet.TweetText.Update();
         var request =
             FluentTwitter.CreateRequest().Users().ShowProfileFor(logininfo.Username).AsJson().Request();
         var profile = request.AsUser();
         currenttweet.TweetImage.Load(profile.ProfileImageUrl);
         currenttweet.TweetText.Font =
             (new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, Byte.Parse("0")));
         currenttweet.TweetText.Text = profile.Status.Text;
         currenttweet.ltimeago.Text = profile.Status.CreatedDate.ToRelativeTime();
         currenttweet.lluser.Text = profile.ScreenName;
         currenttweet.lvia.Text = "via " + Utilities.StripHtml(profile.Status.Source);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Erreur !", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }