I've used TweetSharp api to work with twitter. The following code I am using to search Tweets on twitter. Problem is it does not returning more than first 100 Tweets.
public List<TwitterStatus> SearchTweetsBySearchText(int intTotalRec,string searchText)
{
List<TwitterStatus> lstTwitterStatusRet = new List<TwitterStatus>();
UpdateResetTimeForApplicationForSearch("Moderator");
TwitterApplicationModel twitterApplication = new TwitterApplicationModel();
twitterApplication = TwitterApplicationBL.GetApplicationInstanceForSearch("Moderator");
if (twitterApplication != null)
{
TwitterService service = new TwitterService(twitterApplication.ConsumerKey, twitterApplication.ConsumerSecret, twitterApplication.AccessToken, twitterApplication.AccessTokenSecret);
var twitterSearchResult = service.Search(new SearchOptions { Q = searchText, Count = intTotalRec });
if (service != null)
{
if (service.Response != null)
{
if (service.Response.RateLimitStatus.RemainingHits <= 0)
{
TwitterApplicationBL.UpdateApplicationRemainingHitsForSearch(twitterApplication.TwitterApplicationID, false, service.Response.RateLimitStatus.ResetTime);
}
}
}
if (twitterSearchResult != null)
{
lstTwitterStatusRet = ((List<TwitterStatus>)twitterSearchResult.Statuses);
foreach (TwitterStatus objTwitterStatus in lstTwitterStatusRet)
{
objTwitterStatus.CreatedDate = objTwitterStatus.CreatedDate.AddHours(-4);
}
}
}
return lstTwitterStatusRet;
}
Can any one suggest what can be done?
Twitter search only goes back 5 - 7 days, or 1,500 tweets, whichever comes first. The search API is the same. Any tweets beyond that are not available through any known method (as of now). Twitter has them, but there is no way to get them.
And in your case, one can never get more than 100 results in from a search. So, you need to issue another search using the max_id
in the "next_results" section
more info on paging here https://dev.twitter.com/docs/working-with-timelines
Happy Coding.. :)
来源:https://stackoverflow.com/questions/20682182/tweetsharp-c-sharp-api-search-only-returns-first-100-tweets