Get all tweets with a specific hashtag

I experimented with the Twitter API because I want to show several lists of tweets on a special page.

Among these lists is a list with all tweets containing a specific hashtag (e.g. #test )

However, I cannot find how to get this list in XML or JSON (preferably the latter), does anyone know? It’s also great if you can do it in TweetSharp

+6
twitter tweetsharp
source share
5 answers

You can simply get http://search.twitter.com/search.json?q=%23test to get a list of tweets containing #test in JSON, where %23test is #test URL.

I am not familiar with TweetSharp, but I think there should be a search command that you can use to search for #test , and then convert the resulting tweets to JSON yourself.

+7
source share

Install TweetSharp first using github https://github.com/danielcrenna/tweetsharp

Here is the code to search

 TwitterService service = new TwitterService(); var tweets = service.Search("#Test", 100); List<TwitterSearchStatus> resultList = new List<TwitterSearchStatus>(tweets.Statuses); 

If you have more than one page, you can set up a loop and call each page

  service.Search("#Test", i += 1, 100); 
+9
source share

It seems like with the API the last few months. Here is the updated code:

 TwitterSearchResult res = twitter.Search(new SearchOptions { Q = "xbox" }); IEnumerable<TwitterStatus> status = res.Statuses; 
+4
source share

u access with this url for your search queries. But you need to use OAuth protocols.

https://api.twitter.com/1.1/search/tweets.json?q=%40twitterapi

0
source share

I struggled with the same problem. Here is my vague solution. Programming. It will exit the function when your required number of tweets is received / received.

  string maxid = "1000000000000"; // dummy value int tweetcount = 0; if (maxid != null) { var tweets_search = twitterService.Search(new SearchOptions { Q = keyword, Count = Convert.ToInt32(count) }); List<TwitterStatus> resultList = new List<TwitterStatus>(tweets_search.Statuses); maxid = resultList.Last().IdStr; foreach (var tweet in tweets_search.Statuses) { try { ResultSearch.Add(new KeyValuePair<String, String>(tweet.Id.ToString(), tweet.Text)); tweetcount++; } catch { } } while (maxid != null && tweetcount < Convert.ToInt32(count)) { maxid = resultList.Last().IdStr; tweets_search = twitterService.Search(new SearchOptions { Q = keyword, Count = Convert.ToInt32(count), MaxId = Convert.ToInt64(maxid) }); resultList = new List<TwitterStatus>(tweets_search.Statuses); foreach (var tweet in tweets_search.Statuses) { try { ResultSearch.Add(new KeyValuePair<String, String>(tweet.Id.ToString(), tweet.Text)); tweetcount++; } catch { } } 

}

0
source share

All Articles