Search code examples
c#tweetsharp

TweetSharp Search Always Returns Null


I am trying to get TweetSharp to search with twitter. It always returns null. There is no error or other information. I setup my consumerkey, consumer secret, access token, and token secret

Here is my code:

TwitterService service = new TwitterService(consumerKey, consumerSecret);
service.AuthenticateWith(accessToken, tokenSecret);

SearchOptions options = new SearchOptions { Q = "#VeternsDay", Count = 100, Resulttype = TwitterSearchResultType.Recent };
TwitterSearchResult searchedTweets = service.Search(options);
return searchedTweets;

Solution

  • I know this question is old, but I was playing around C# and Tweetsharp and saw your question and tried to solve it :)

    I tried to recreate your example and I got it working! You needed to loop over the searchedTweets.Statuses and get their contents. In this example I got the 100 popular tweets in the #Bahrain hashtag and got those tweets username authors.

    var service = new TwitterService(consumerKey, consumerSecret);
    service.AuthenticateWith(accessToken, accessTokenSecret);
    SearchOptions options = new SearchOptions { Q = "#Bahrain", Count = 100, Resulttype = TwitterSearchResultType.Popular};
    TwitterSearchResult searchedTweets = service.Search(options);
    foreach(var tweet in searchedTweets.Statuses)
    {
         MessageBox.Show( tweet.Author.ScreenName);
    }