Revert all tweets from my timeline

I want to return ALL tweets that I have ever published on my timeline.

I use the Linq To Twitter library like this -

var statusTweets = from tweet in twitterCtx.Status where tweet.Type == StatusType.User && tweet.UserID == MyUserID && tweet.Count == 200 select tweet; statusTweets.ToList().ForEach( tweet => Console.WriteLine( "Name: {0}, Tweet: {1}\n", tweet.User.Name, tweet.Text)); 

This works fine and returns the first 200. However, the first 200 seem to be the maximum that I can get, since there is a way to return 1000 words? It seems that there is no next cursor movement option, for example, in other parts of this library to go to the next pages, etc.

+4
source share
1 answer

You used a combination of Count, MaxID, and SinceID to go through tweets. This sounds strange, but there is a very good reason for this approach, given that the stream of tweets is constantly updated. I wrote a blog post, Working with Timeline with LINQ to Twitter , which points to Twitter documentation and describes how LINQ to Twitter does it.

 // last tweet processed on previous query set ulong sinceID = 210024053698867204; ulong maxID; const int Count = 10; var statusList = new List<status>(); var userStatusResponse = (from tweet in twitterCtx.Status where tweet.Type == StatusType.User && tweet.ScreenName == "JoeMayo" && tweet.SinceID == sinceID && tweet.Count == Count select tweet) .ToList(); statusList.AddRange(userStatusResponse); // first tweet processed on current query maxID = userStatusResponse.Min( status => ulong.Parse(status.StatusID)) - 1; do { // now add sinceID and maxID userStatusResponse = (from tweet in twitterCtx.Status where tweet.Type == StatusType.User && tweet.ScreenName == "JoeMayo" && tweet.Count == Count && tweet.SinceID == sinceID && tweet.MaxID == maxID select tweet) .ToList(); if (userStatusResponse.Count > 0) { // first tweet processed on current query maxID = userStatusResponse.Min( status => ulong.Parse(status.StatusID)) - 1; statusList.AddRange(userStatusResponse); } } while (userStatusResponse.Count != 0 && statusList.Count < 30); 
+4
source

Source: https://habr.com/ru/post/1500748/


All Articles