Exclude Retweets with LinqToTwitter

My LinqToTwitter class cannot exclude retweets.

var srch = (from search in twitterCtx.Search where search.Type == SearchType.Search && search.Query == term && search.Count == 100 select search).SingleOrDefault();

There is no option search.IncludeRetweets==false.

How can I do a search? Should I try a different class?

+3
source share
2 answers

The Twitter API does not offer this option, so LINQ and Twitter do not. However, here is what you can do:

  • Complete your search query as usual. It will contain retweets.
  • Run a LINQ to Objects query on the results using the where clause, which sets the RetweetedStatus.StatusID == 0 condition, for example:

    var nonRetweetedStatuses =
        (from tweet in searchResponse.Statuses
         where tweet.RetweetedStatus.StatusID == 0
         select tweet)
        .ToList();
    

, where, , , LINQ to Twitter RetweetedStatus, , . . StatusID 0 retweet, . , Text == null, .

+6

exclude:replies / exclude:retweets:

term = term + " exclude:replies exclude:retweets";
0

All Articles