storage timeline

Nov 10, 2013 at 7:48 PM
Hi

Can i use this library for download all time line incluiding retweetn, and tweets of my own timeline and export to a file,??? it is possible doing this with this library???.

Regards.
Víctor.
Coordinator
Nov 10, 2013 at 8:28 PM
Edited Nov 10, 2013 at 8:29 PM
Hi,

This is not implemented directly out of the box but this is not very difficult to implement it.
Here is a solution I created for you :)
static List<ITweet> GetAllMyTimeline(IToken token, string username)
{
    const int maxId = 200;
    string query = String.Format("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name={0}&count={1}", username, maxId);
    List<ITweet> allTweets = ResultGenerator.GetTweets(token, query);
    List<ITweet> latestTweets = allTweets;

    while (latestTweets.Count == maxId)
    {
        long oldestTweetId = (long)latestTweets.Last().Id;
        query = String.Format("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name={0}&max_id={1}&count={2}", username, oldestTweetId, maxId);
        latestTweets = ResultGenerator.GetTweets(token, query);
        allTweets.AddRange(latestTweets);
    }

    return allTweets;
}
Linvi
Nov 10, 2013 at 11:15 PM
Hi Linvi :

Thanks a lot for the quickly reply and workign with this funcions you give and in the variable

ResultGenerator that no exist in the current context ???

I have download and compile the last source code.

What is wrong????
Nov 10, 2013 at 11:23 PM
Hello Linvi:

I have checked the source code where is the ResutGenerator and see my mistake.

I have import the using Tweetinvi.Helpers; in my headers.

and compile correctly. Rigt now testing.

Thanks a lot forr the great support.

Regards.
Víctor.
Nov 10, 2013 at 11:33 PM
Hi Linvi:

I have tested the function and just give the 200 early tweets, there is a way to gime ve the all timeline with my al 1555 tweets????.

Regards.
Víctor.
Coordinator
Nov 10, 2013 at 11:33 PM
You're welcome.

Let me know if this works.

Linvi
Coordinator
Nov 10, 2013 at 11:36 PM
I am going to bed right now but I will have a look tomorrow.
In the meantime could you please give me the User screen_name or user_id of the account you'd like to get all the tweets from so that I have a look into it.

Linvi
Nov 11, 2013 at 12:22 AM
Hi Linvi :

Thansk for the quickly reply and great support the username of timeline i downloading is _news_www

Regards.
Víctor.
Coordinator
Nov 11, 2013 at 7:56 AM
Hi Victor,

The code I sent previously is working perfectly fine for me on your account.
Here is how I called the function.
GetAllMyTimeline(token, "_news_www");
And I received 1109 tweets. Would you please verify what is the behavior of the code within the loop.
Meaning can you verify the number of tweets you receive the second time you call the twitter API.

Regards,
Linvi
Nov 11, 2013 at 4:48 PM
HI linvi:

Yea right Now is working but i tried with the count victor__deleon and akirareiko and Just retrive 3200 tweets and not All the timeline about 6000 tweets

Regards.
Víctor.
Coordinator
Nov 11, 2013 at 7:13 PM
Hi Victor,

I did not know that you required more than 3200 tweets as it is the limit of tweets you can receive with the Timeline REST API from Twitter.
I will have a look later today to see if it is possible to receive more than 3200 tweets with the Search API.

For reference :
This method can only return up to 3,200 of a user's most recent Tweets. Native retweets of other statuses by the user is included in this total, regardless of whether include_rts is set to false when requesting this resource. (User Timeline Documentation)
Linvi
Coordinator
Nov 11, 2013 at 9:01 PM
After doing some research, Twitter does not provide any reliable solution to get Tweets older than the 3200.
This has been explained by the developer of the Twitter API, they tell that it is not possible to get tweets older than 3200 and if developers wants to do this, they need to record all the tweets by themselves (using for example the UserStream.

For users already having more than 3200 tweets there is currently no solution that I can find.

Sorry about this response but this is a limitation that I cannot overcome.
Hope you understand.

Linvi
Nov 12, 2013 at 4:57 AM
Hello Linvi :

One more time thanks a lot for quickly reply, and great support. I have doing some research too, and as you said the limit for get tweets is 3200, i have read that you can get older tweets if you have the id. It would be great that i can get all tweets of timeline. I want to make some statistics, some web site like. www.tweetstats.com get all the tweets i wan to make something like this, i do not know ow retrive all the tweet line. I keep looking for some solution for get more that 3200 and let you know.

One more time thanks a gain for the great support. Tweetinvi is a great library and i will still using for my project and give feed back, and i will help in anything i can do for get better this project.

If you have comments or questions please let me know.

Regards.
Víctor.
Coordinator
Nov 12, 2013 at 9:48 AM
Hey,

I cannot make tweetstats work on any account personally but it seems to be able to retrieve a big number of tweets.
As you said "i have read that you can get older tweets if you have the id", this is true, and this is why I would recommend you to store the tweets id of your account in a database so that you can retrieve them later. To ensure that each time a tweet is posted you store it, use the UserStream. Even though this solution does not solve your problem it should help you making statistics starting from previous 3200 and continue refining the results over time.

For the tweets previous to the 3200, I still haven't found any solution.
Let me know if you do!

Linvi