我正在尝试使用TweetSharp获取最近的200条推文但由于某种原因返回12。
var service = new TwitterService(
_consumerKey,
_consumerSecret,
tokenClaim,
tokenSecret
);
IAsyncResult result = service.BeginListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { Count = 200}
IEnumerable<TwitterStatus> tweets = service.EndListTweetsOnUserTimeline(result);
任何想法为什么会这样?感谢
更新
关注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是空的。
答案 0 :(得分:5)
TweetSharp是一个旧库,不再维护。众所周知,它存在身份验证问题,但很有可能是因为Twitter API更改而导致其他问题。只是不要浪费你的时间来修复它。
我建议您使用Linq2Twitter
上提供的最新库NuGet。
使用LinqToTwitter
,您的代码将如下所示:
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;
}
}