public TweetsApiService(TwitterDbcontext context) { _context = context; _credentials = MyCredentials.GenerateCredentials(); Auth.SetCredentials(_credentials); }
public TweetController(TweetsApiService tweetsApiService) { _credentials = MyCredentials.GenerateCredentials(); Auth.SetCredentials(_credentials); _tweetsApiService = tweetsApiService; }
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)); }
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); }
public TweetController() { _credentials = MyCredentials.GenerateCredentials(); }
private static ITwitterClient GetAppClient() { var appCreds = MyCredentials.GenerateAppCreds(); return(new TwitterClient(appCreds)); }