-
Notifications
You must be signed in to change notification settings - Fork 218
Searches
Twitter gives the ability to developers to search for Tweets and Users. Though you need to be aware that the Tweet results are limited to the past 1 to 2 weeks.
This restriction is quite significant for researchers who will probably consider this sample too limited. In such cases you will need to consider using the streams, especially the SampleStream and FilteredStream.
Before we even start speaking about code, you need to be aware that tweet searches are limited to a very restricted period of time. It is safe to consider that every tweet published in the last 7 days will be available. If you want to get tweets from an older period please note that the results might not be accurate.
Twitter Description
It’s important to know that the Search API is focused on relevance and not completeness. This means that some Tweets and users may be missing from search results. If you want to match for completeness you should consider using a Streaming API instead.
In order to create a search please read carefully how to format your search query in the Twitter documentation.
// Simple Search
var matchingTweets = Search.SearchTweets("tweetinvi");
We have tried to simplify the access to the search api in Tweetinvi by providing additional parameters that you can set as followed.
var searchParameter = new SearchTweetsParameters("tweetinvi")
{
GeoCode = new GeoCode(-122.398720, 37.781157, 1, DistanceMeasure.Miles),
Lang = LanguageFilter.English,
SearchType = SearchResultType.Popular,
MaximumNumberOfResults = 100,
Until = new DateTime(2015, 06, 02),
SinceId = 399616835892781056,
MaxId = 405001488843284480,
Filters = TweetSearchFilters.Images
};
var tweets = Search.SearchTweets(searchParameter);
Twitter gives less control over User searches and they are therefore quite simple to use in Tweetinvi.
var users = Search.SearchUsers("<user_search>");
User Searches uses pages to iterate over the search result.
// Get users of page number 2
var users = Search.SearchUsers("user_name", page : 2);