我现在每天都会接受两次喂食。我正在使用tweetinvi Api,我的代码只获取最新的200个源,我想要所有。
我的代码是 公共函数getTweets()
''Set the credentials
Dim lObjConsumerKey As String = "[REDACTED]"
Dim lObjConsumerSecret As String = "[REDACTED]"
Dim lObjUserAccessToken As String = "[REDACTED]"
Dim lObjUserAccessSecret As String = "[REDACTED]"
Auth.SetUserCredentials(lObjConsumerKey, lObjConsumerSecret, lObjUserAccessToken, lObjUserAccessSecret)
Dim lObjDataTable As New DataTable
lObjDataTable.Columns.Add("Tweets")
lObjDataTable.Columns.Add("CreatedAt")
Dim GetTimelineTweets = Timeline.GetUserTimeline(txtUserName.Text)
For Each lobjGetgetTweets In GetTimelineTweets
Dim drNew = lObjDataTable.NewRow
drNew("Tweets") = lobjGetgetTweets
drNew("CreatedAt") = lobjGetgetTweets.CreatedAt
lObjDataTable.Rows.Add(drNew)
Next
Return lObjDataTable
End Function
答案 0 :(得分:1)
根据GetUserTimeline()的Twitter REST API文档,此行为是设计使然。在count参数的定义中......
指定要尝试和检索的推文数量,最多为 每个不同的请求200。
要获取所有推文,请在Twitter开发者网站上查看Working With Timelines。
答案 1 :(得分:0)
我在文档中为您创建了一个示例:https://github.com/linvi/tweetinvi/wiki/Get-All-User-Tweets
RateLimit.RateLimitTrackerMode = RateLimitTrackerMode.TrackAndAwait;
RateLimit.QueryAwaitingForRateLimit += (sender, args) =>
{
Console.WriteLine($"Query : {args.Query} is awaiting for rate limits!");
};
long userId = <YOUR_USER_ID>;
var lastTweets = Timeline.GetUserTimeline(userId, 200).ToArray();
var allTweets = new List<ITweet>(lastTweets);
var beforeLast = allTweets;
while (lastTweets.Length > 0 && allTweets.Count <= 3200)
{
var idOfOldestTweet = lastTweets.Select(x => x.Id).Min();
Console.WriteLine($"Oldest Tweet Id = {idOfOldestTweet}");
var numberOfTweetsToRetrieve = allTweets.Count > 3000 ? 3200 - allTweets.Count: 200;
var timelineRequestParameters = new UserTimelineParameters
{
// MaxId ensures that we only get tweets that have been posted
// BEFORE the oldest tweet we received
MaxId = idOfOldestTweet - 1,
MaximumNumberOfTweetsToRetrieve = numberOfTweetsToRetrieve
};
lastTweets = Timeline.GetUserTimeline(userId, timelineRequestParameters).ToArray();
allTweets.AddRange(lastTweets);
}
// `allTweets` now contains all the tweets that Twitter can return