Ali Ylmaz

Ali Ylmaz

  • NA
  • 129
  • 11.6k

linq-to-twitter Twitter flood get

May 24 2020 1:48 PM

I tried the code below but again it wasn't exactly as I wanted. Only 1 pearl flood is coming. There are 90 floods. RT ones should not come and should only come flood by call.

as an example I shared the picture. What do I have to do in this situation.
  1. const int MaxSearchEntriesToReturn = 100;  
  2.         const int SearchRateLimit = 180;  
  3.   
  4.         string searchTerm = "HANEDANLAR MASASININ YER ALTI EGEMENLIGI:RIO TINTO";  
  5.   
  6.         // oldest id you already have for this search term  
  7.         ulong sinceID = 1;  
  8.   
  9.         // used after the first query to track current session  
  10.         ulong maxID;  
  11.   
  12.         var combinedSearchResults = new List();  
  13.   
  14.         List searchResponse =  
  15.             await  
  16.             (from search in ctx.Search  
  17.              where search.Type == SearchType.Search &&  
  18.                    search.Query == searchTerm &&  
  19.                    search.Count == MaxSearchEntriesToReturn &&  
  20.                    search.SinceID == sinceID &&  
  21.                    search.TweetMode == TweetMode.Extended  
  22.              select search.Statuses)  
  23.             .SingleOrDefaultAsync();  
  24.   
  25.         if (searchResponse != null)  
  26.         {  
  27.             combinedSearchResults.AddRange(searchResponse);  
  28.             ulong previousMaxID = ulong.MaxValue;  
  29.             do  
  30.             {  
  31.                 // one less than the newest id you've just queried  
  32.                 maxID = searchResponse.Min(status => status.StatusID) - 1;  
  33.   
  34.                 Debug.Assert(maxID < previousMaxID);  
  35.                 previousMaxID = maxID;  
  36.   
  37.                 searchResponse =  
  38.                     await  
  39.                     (from search in ctx.Search  
  40.                      where search.Type == SearchType.Search &&  
  41.                            search.Query == searchTerm &&  
  42.                            search.Count == MaxSearchEntriesToReturn &&  
  43.                            search.MaxID == maxID &&  
  44.                            search.SinceID == sinceID &&  
  45.                            search.TweetMode == TweetMode.Extended  
  46.                      select search.Statuses)  
  47.                     .SingleOrDefaultAsync();  
  48.   
  49.                 combinedSearchResults.AddRange(searchResponse);  
  50.             } while (searchResponse.Any() && combinedSearchResults.Count < SearchRateLimit);  
  51.   
  52.   
  53.             combinedSearchResults.ForEach(tweet =>   
  54.                 Console.WriteLine(  
  55.                     "\n  User: {0} ({1})\n  Tweet: {2}",  
  56.   
  57.                     tweet.User.ScreenNameResponse,  
  58.                     tweet.User.UserIDResponse,  
  59.                     tweet.Text ?? tweet.FullText)  
  60.                 );  
  61.         }  
  62.         else  
  63.         {  
  64.             Console.WriteLine("No entries found.");  
  65.         }  
  66.   
  67.         ViewBag.Twet = combinedSearchResults.ToList()  
 

Answers (1)