Example #1
0
        private void AddTimeLineTweets()
        {
            IEnumerable <Tweetinvi.Core.Interfaces.ITweet> tweets;

            if (User.GetAuthenticatedUser().ScreenName == this.Selecteduser.ScreenName)
            {
                var homeTimelineParameter = new HomeTimelineParameters
                {
                    MaxId = this.TimeLineTweets.Last().Id,
                    MaximumNumberOfTweetsToRetrieve = 15
                };
                tweets = Timeline.GetHomeTimeline(homeTimelineParameter);
            }
            else
            {
                var userTimelineParameters = new UserTimelineParameters
                {
                    MaxId = this.TimeLineTweets.Last().Id,
                    MaximumNumberOfTweetsToRetrieve = 15
                };
                tweets = Timeline.GetUserTimeline(this.Selecteduser.Id, userTimelineParameters);
            }
            var tweetsList = tweets.ToList();

            tweetsList.RemoveAt(0);
            foreach (var tweet in tweetsList)
            {
                this.TimeLineTweets.Add((Tweet)tweet);
            }
        }
Example #2
0
        public bool ProfileTimeLineHasTweets(TwitterProfile profile)
        {
            if (profile == null)
            {
                return(false);
            }

            if (profile.Name == null)
            {
                return(false);
            }

            var user = User.GetUserFromScreenName(profile.Name);

            if (user == null)
            {
                return(false);
            }

            var timelineParameter = Timeline.CreateHomeTimelineParameter();

            timelineParameter.ExcludeReplies  = true;
            timelineParameter.TrimUser        = true;
            timelineParameter.IncludeEntities = false;

            var timeLine = Timeline.GetUserTimeline(user);

            return(timeLine != null);
        }
        public List <Models.User> GetUserFollowers()
        {
            var model  = new List <Models.User>();
            var result = Auth.ExecuteOperationWithCredentials(_credentialService.GetUserCredentials(), () =>
            {
                // Get the first 250 followers of the user
                var followers         = User.GetFollowers(User.GetAuthenticatedUser(_credentialService.GetUserCredentials()).ScreenName);
                IEnumerator <IUser> e = followers.GetEnumerator();
                while (e.MoveNext())
                {
                    model.Add(new Models.User
                    {
                        Name            = e.Current.Name,
                        ScreenName      = e.Current.ScreenName,
                        StatusesCount   = e.Current.StatusesCount,
                        FollowersCount  = e.Current.FollowersCount,
                        FriendsCount    = e.Current.FriendsCount,
                        ProfileImage    = e.Current.ProfileImageUrl,
                        BackgroundImage = e.Current.ProfileBannerURL
                    });
                }
                return(model);
            });

            return(result);
        }
Example #4
0
 public TimeLinePageViewModel()
 {
     this.Selecteduser      = (Tweetinvi.Logic.User)User.GetAuthenticatedUser();
     this.TimeLineTweets    = getTimeLineObservableCollection(this.Selecteduser);
     this._headerText       = "Welcome @" + this.Selecteduser.Name;
     this._nbCharacterTweet = 140;
     this._stringPostTweet  = "Characters left : " + this._nbCharacterTweet;
     this.MediasTweet       = new List <Tweetinvi.Core.Interfaces.DTO.IMedia>();
 }
        public string SendTweet(string newTweet)
        {
            var sanitizer = new HtmlSanitizer();
            var sanitized = sanitizer.Sanitize(newTweet);
            var user      = User.GetAuthenticatedUser(_credentialService.GetUserCredentials());
            var tweet     = user.PublishTweet(sanitized);

            return(!tweet.Text.IsNullOrEmpty() ? sanitized : "An error has occured!");
        }
Example #6
0
 private void SetUserTimeLine()
 {
     if (!String.IsNullOrEmpty(this._userNameInput))
     {
         var user = (Tweetinvi.Logic.User)User.GetUserFromScreenName(this._userNameInput);
         if (user != null)
         {
             this.Selecteduser   = user;
             this.TimeLineTweets = this.getTimeLineObservableCollection(this.Selecteduser);
             this._userNameInput = "";
         }
     }
 }
Example #7
0
 /// <summary>
 /// Gets eztv timeline
 /// </summary>
 /// <param name="count">currently non-functional</param>
 /// <returns>List of tweets from timeline</returns>
 public List<ITweet> GetRecentTweets(int count)
 {
     List<ITweet> timeline = new List<ITweet>();
     try
     {
         User user = new User(_userID, _token, true);
         timeline = user.GetUserTimeline();
     }
     catch (Exception e)
     {
         //yeezus christ improve this bullshit
         throw e;
     }
     return timeline;
 }
        public Models.User ValidateTwitterAuth()
        {
            var user = User.GetAuthenticatedUser(_credentialService.GetUserCredentials());

            var model = new Models.User();

            model.Name            = user.Name;
            model.ScreenName      = user.ScreenName;
            model.FollowersCount  = user.FollowersCount;
            model.FriendsCount    = user.FriendsCount;
            model.StatusesCount   = user.StatusesCount;
            model.ProfileImage    = user.ProfileImageUrl;
            model.BackgroundImage = user.ProfileBannerURL;

            return(model);
        }
Example #9
0
        public ObservableCollection <Tweetinvi.Logic.Tweet> getTimeLineObservableCollection(Tweetinvi.Logic.User user)
        {
            IEnumerable <Tweetinvi.Core.Interfaces.ITweet> timeLine;

            if (User.GetAuthenticatedUser().ScreenName == this.Selecteduser.ScreenName)
            {
                timeLine = Timeline.GetHomeTimeline();
            }
            else
            {
                timeLine = Timeline.GetUserTimeline(user);
            }
            var timeLineCollection = new ObservableCollection <Tweet>();

            timeLine = timeLine.Where(t => t.InReplyToScreenName == null).ToList();
            //timeLine = Timeline.GetUserTimeline("AmandaCerny");
            foreach (var tweet in timeLine)
            {
                timeLineCollection.Add((Tweetinvi.Logic.Tweet)tweet);
            }
            return(timeLineCollection);
        }
Example #10
0
        public List <Models.Tweet> GetUserTweets()
        {
            var user       = User.GetAuthenticatedUser(_credentialService.GetUserCredentials());
            var userTweets = user.GetHomeTimeline();
            var model      = new List <Models.Tweet>();

            IEnumerator <ITweet> e = userTweets.GetEnumerator();

            while (e.MoveNext())
            {
                model.Add(new Models.Tweet
                {
                    Text             = e.Current.Text,
                    CreatedAt        = e.Current.CreatedAt,
                    UserProfileImage = e.Current.CreatedBy.ProfileImageUrl,
                    UserName         = e.Current.CreatedBy.Name,
                    ScreenName       = e.Current.CreatedBy.ScreenName,
                    Id        = e.Current.Id,
                    UserTweet = e.Current
                });
            }
            return(model);
        }
        public void Execute(IJobExecutionContext context)
        {
            int skippedOld = 0;

            var users = new List<String> { "jbask14", "bockingselmbabe", "gemmagwynne", "dorotheecomp77", "angelaevans247", "flossiecrossie" };
            foreach (var username in users)
            {
                try
                {
                    var user = new User(username, _twitterToken);
                    List<ITweet> statuses =
                        user.GetUserTimeline(true, _twitterToken).Where(s => s.Id > _lastStatus[username]).ToList();
                    _logger.InfoFormat("User {0}: {1} new statuses", username, statuses.Count);
                    foreach (var status in statuses)
                    {
                        if (status.CreatedAt.ToUniversalTime() < DateTime.UtcNow.AddHours(-12))
                        {
                            skippedOld++;
                            continue;
                        }
                        if (status.Retweeting != null)
                        {
                            var source = String.Format("https://twitter.com/{0}/status/{1}",
                                                       status.Creator.ScreenName, status.IdStr);
                            //this is a retweet
                            var targetStatus = status.Retweeting;

                            _queue.EnqueueRetweet(targetStatus.IdStr, source);
                            _queue.EnqueueFollow(targetStatus.Creator.ScreenName.ToLower(), source);

                            //also follow any mentioned users
                            foreach (var entity in targetStatus.UserMentions)
                            {
                                _queue.EnqueueFollow(entity.ScreenName.ToLower(), source);
                            }
                        }
                    }

                    try
                    {
                        if (statuses.Any() && statuses.First().Id.HasValue)
                        {
                            _lastStatus[username] = statuses.First().Id.Value;
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.ErrorFormat("Error setting last staus id:\n {0}", ex);
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error(ex);
                }
            }

            if (skippedOld > 0)
                _logger.InfoFormat("Skipped {0} old tweets", skippedOld);

            _logger.Info("Twitter scrape complete");
        }
 private void Follow(string userId)
 {
     _logger.InfoFormat("Attempting to follow {0}", userId);
     var me = new TokenUser(_twitterToken);
     _logger.Info("Got tokenuser");
     var toFollow = new User(userId, _twitterToken);
     _logger.Info("Got toFollow");
     me.Follow(toFollow, true);
     _logger.InfoFormat("Followed user {0}", userId);
 }
Example #13
0
 public TwitterApi()
 {
     Auth.SetUserCredentials("rU8vaV2mpDHTsYTQsTnItYM18", "IvfT0wiKSrtZWyKJIwaWe7UnuEB8eKfAi2MnUSvRv9ZmBGe4Sc",
                             "1002850919506235392-zemHXViy61kXHc2yZr9LiwwOdibYSn", "1kvW578ahJo6E0kX3qCKEA5T35JyyUoYfTdZKR7E8QhgB");
     TwitUser = User.GetAuthenticatedUser();
 }