简体   繁体   中英

Twitterizer - C# Code to Search Tweets From Only Users I Follow

I am currently using Twitterizer to search through public tweets using C#:

    private void QueryTwitter()
{
  SearchOptions myOptions = new SearchOptions();
  myOptions.CacheTimespan = new TimeSpan(0, 15, 0);
  //myOptions.ResultType = SearchOptionsResultType.Popular;
  string searchTerm = "\"" + Player.GetPlayer(this.PlayerID).FullName + "\"";
  TwitterResponse<TwitterSearchResultCollection> recentTweets = TwitterSearch.Search(searchTerm, myOptions);
  repTweets.DataSource = recentTweets.ResponseObject;
  repTweets.DataBind();
}

What I'd like to do is search through tweets from only the people that I follow. Is there any way to do this?

The search api is a non-authenticated endpoint, so it does not have any knowledge of who you are. Because of this, there is no baked in way of filtering tweets to only show people that you follow.

It is possible, however, to construct a query that specifies the author of tweets, if you add something like this to your query: (from:user1 OR from:user2 OR from:user3)

For example, my query string would be: "stream (from:twitterapi OR from:sitestreams)"

Keep in mind that the search api has complexity limits, so you will not be able to request all of your followers in a single query. If I were to guess, I'd say you'll get no more than 5 users at a time. You'll have to combine the results into a single list yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM