I am trying to get recent 200 tweets using TweetSharp but it is returning 12 for some reason.
var service = new TwitterService(
_consumerKey,
_consumerSecret,
tokenClaim,
tokenSecret
);
IAsyncResult result = service.BeginListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { Count = 200}
IEnumerable<TwitterStatus> tweets = service.EndListTweetsOnUserTimeline(result);
Any ideas why would that be? Thanks
Update
Following How to fetch maximum 800 tweets from ListTweetOnHomeTimeline() method of TweetSharp?
IAsyncResult result =
_twitterService.BeginListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { Count = 200 });
IEnumerable<TwitterStatus> tweets = _twitterService.EndListTweetsOnUserTimeline(result).ToArray();
var tweet2 = _twitterService.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { Count = 200, MaxId = tweets.Last().Id });
return tweet2;
tweet2 is empty.
TweetSharp is an old library and no longer maintained. It is known to have authentication problems, but big chance is that you're bumping against an other issue due to Twitter API changes. Just don't waste your time trying to fix it.
I suggest you to use the more up-to-date library Linq2Twitter
which is also available on NuGet.
With LinqToTwitter
your code would look like:
static async Task<List<Status>> ListTweetsOnUserTimeline(string screenName)
{
var auth = new SingleUserAuthorizer
{
CredentialStore = new SingleUserInMemoryCredentialStore
{
ConsumerKey = consumerKey,
ConsumerSecret = consumerSecret,
AccessToken = accessToken,
AccessTokenSecret = accessTokenSecret
}
};
using (var context = new TwitterContext(auth))
{
var tweets = await (from tweet in context.Status
where tweet.Type == StatusType.User &&
tweet.Count == 200 &&
tweet.ScreenName == screenName
select tweet)
.ToListAsync();
return tweets;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With