Return all tweets

Feb 14, 2014 at 2:17 PM
Hi Mr. Joe

I want to ask you about returning all tweets. I follow this code of yours :
// 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);
But then i got some errors on it. My questions are :
  1. Can i use directly that sinceID into my project? Or do i need to get it first?
  2. In var statusList = new List<status>(); --> is that status class?
  3. In maxID = userStatusResponse.Min(status => ulong.Parse(status.StatusID)) - 1;
    I got some error when parsing ulong. It also says sequence contain no element. What should i do about it?
Sorry for asking you a lot. I appreciate your help. Thank you.

Regards,


Marshall
Feb 15, 2014 at 1:32 AM
Not Joe, but some help:

1) the sinceID is specific to your application / tweet list. That said, I've been able to just start with a value of "1" and have it work just fine.
2) status is the linqtotwitter object for a tweet
3) I had to take that ulong.Parse() check out of my code, as the StatusID was already an ulong for me, and parse was expecting a string. So mine worked like this:
maxID = userStatusResponse.Min(status => status.StatusID) - 1;
Feb 28, 2014 at 8:47 AM
Hi jbart08,

Thank you for your explanation. Do you have some demo project so that i can more understand?