Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
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>();
 }
Exemplo n.º 4
0
        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!");
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
 public static async Task <IAuthenticatedUser> GetAuthenticatedUser(ITwitterCredentials credentials)
 {
     return(await Sync.ExecuteTaskAsync(() => User.GetAuthenticatedUser(credentials)));
 }
Exemplo n.º 9
0
 // User Factory
 public static async Task <IAuthenticatedUser> GetAuthenticatedUser()
 {
     return(await Sync.ExecuteTaskAsync(() => User.GetAuthenticatedUser()));
 }
Exemplo n.º 10
0
 public TwitterApi()
 {
     Auth.SetUserCredentials("rU8vaV2mpDHTsYTQsTnItYM18", "IvfT0wiKSrtZWyKJIwaWe7UnuEB8eKfAi2MnUSvRv9ZmBGe4Sc",
                             "1002850919506235392-zemHXViy61kXHc2yZr9LiwwOdibYSn", "1kvW578ahJo6E0kX3qCKEA5T35JyyUoYfTdZKR7E8QhgB");
     TwitUser = User.GetAuthenticatedUser();
 }