예제 #1
0
        public TweetsApiService(TwitterDbcontext context)
        {
            _context     = context;
            _credentials = MyCredentials.GenerateCredentials();

            Auth.SetCredentials(_credentials);
        }
예제 #2
0
        public TweetController(TweetsApiService tweetsApiService)
        {
            _credentials = MyCredentials.GenerateCredentials();

            Auth.SetCredentials(_credentials);
            _tweetsApiService = tweetsApiService;
        }
예제 #3
0
        public ViewResult SearchResults(IndexViewModel searchParams)
        {
            Auth.SetCredentials(MyCredentials.GenerateCredentials());

            SearchTweetsParameters searchTweetsParameters = new SearchTweetsParameters(searchParams.Query)
            {
                SearchType             = searchParams.Type,
                MaximumNumberOfResults = searchParams.MaxResults
            };

            if (searchParams.HasLocation)
            {
                searchTweetsParameters.GeoCode.Coordinates.Latitude  = searchParams.Lat;
                searchTweetsParameters.GeoCode.Coordinates.Longitude = searchParams.Long;
                // TODO: only miles for now...
                searchTweetsParameters.GeoCode.DistanceMeasure = DistanceMeasure.Miles;
            }

            var matchingTweets = Search.SearchTweets(searchTweetsParameters);

            if (searchParams.HasLocation)
            {
                matchingTweets = matchingTweets.Where(p => p.Coordinates != null || !p.CreatedBy.Location.IsNullOrEmpty());
            }

            // Store the search results in TweetRepository so they are available application-wide.
            if (!TweetRepository.SearchResults.IsNullOrEmpty())
            {
                TweetRepository.SearchResults.Clear();
            }

            return(View(matchingTweets));
        }
예제 #4
0
        public void Getting_Back_Tweets_From_API_With_TwitterInvi()
        {
            string input  = "i";
            double lat    = 59.3293;
            double lng    = 18.0686;
            int    radius = 50;


            var _credentials = MyCredentials.GenerateCredentials();

            Auth.SetCredentials(_credentials);

            List <ITweet> matchingTweets = TweetsApiService.GetTweets(input, lat, lng, radius);

            Assert.IsNotNull(matchingTweets);
        }
예제 #5
0
 public TweetController()
 {
     _credentials = MyCredentials.GenerateCredentials();
 }
예제 #6
0
        private static ITwitterClient GetAppClient()
        {
            var appCreds = MyCredentials.GenerateAppCreds();

            return(new TwitterClient(appCreds));
        }