public HomeController(TwitsDataContext twitsContext, TwittService TwittService, TwittImageService TwittImageService, HubManager HubManager, TwitterApiService TwitterApiService)
 {
     _twitsContext      = twitsContext;
     _TwittService      = TwittService;
     _TwittImageService = TwittImageService;
     _HubManager        = HubManager;
     _TwitterApiService = TwitterApiService;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Posts a tweet to Twitter with the specified text.
        /// </summary>
        /// <param name="text">The text to tweet.</param>
        private void PostTweet(string text)
        {
            TwitterApiService twitterApi = new TwitterApiService(
                _configuration.GetSection("UserSecrets").GetSection("WebServicesCredentials").GetSection("TwitterAPI")["ApiKey"],
                _configuration.GetSection("UserSecrets").GetSection("WebServicesCredentials").GetSection("TwitterAPI")["ApiKeySecret"],
                _configuration.GetSection("UserSecrets").GetSection("WebServicesCredentials").GetSection("TwitterAPI")["OAuthToken"],
                _configuration.GetSection("UserSecrets").GetSection("WebServicesCredentials").GetSection("TwitterAPI")["OAuthTokenSecret"]
                );

            twitterApi.PostTweetAsync(text);
        }
Ejemplo n.º 3
0
        public TwitterModel(TwitterModeEnum mode, int count, string screenName, Int64 tweetId = -1)
        {
            this.Mode = mode;

            this.Tweets = new List <TwitterStatus>();
            var service = new TwitterApiService();

            this.Error = false;

            try
            {
                switch (mode)
                {
                case TwitterModeEnum.SpecificTweet:
                    if (tweetId != -1)
                    {
                        this.Tweets.AddRange(service.Get(new TwitterTweetRequest()
                        {
                            Id = tweetId
                        }));
                    }
                    break;

                case TwitterModeEnum.HomeTimeline:
                    this.Tweets.AddRange(service.Get(new TwitterHomeTimelineRequest()
                    {
                        Take = count + 1
                    }));
                    break;

                case TwitterModeEnum.MentioningMe:
                    this.Tweets.AddRange(service.Get(new TwitterMentionsTimelineRequest()
                    {
                        Take = count
                    }));
                    break;

                case TwitterModeEnum.UserTimeline:
                    this.Tweets.AddRange(service.Get(new TwitterUserTimelineRequest()
                    {
                        ScreenName = screenName, Take = count
                    }));
                    break;
                }
            }catch (Exception ex)
            {
                this.Error        = true;
                this.ErrorMessage = ex.Message;
            }
        }
Ejemplo n.º 4
0
 public TweetController()
 {
     _tweetDbService    = new TweetDbService();
     _twitterApiService = new TwitterApiService();
 }