Get Statuses from List members in which the List Owner is Mentioned

Dec 20, 2013 at 10:53 PM
Edited Dec 20, 2013 at 11:10 PM
I have a private List to which a number of authenticated users (I have their tokens) have been added. I need to retrieve tweets by list members in which the List Owner ("me") is mentioned.
  TwitterContext twitterCtx = new TwitterContext(auth);
            var statusList =
                (from list in twitterCtx.List
                 where list.Type == ListType.Statuses &&
                       list.OwnerScreenName == uxUserName.Text &&
                       list.Slug == uxTxtListName.Text // name of list to get statuses for
                 select list).First();
where 'auth' contains List Owner's credentials and one can then loop the statusList for each tweet to check for a mention.

I also found how to get mentions for a user, in which case I would then loop through each to see whether the sender belongs to the List.

Is there a better way to do this? If not which method would you recommend?

Thanks v much for any guidance!

P.S. - Happy Holidays to all!
Dec 20, 2013 at 11:48 PM

Your approach looks correct to me. At this point, there might be some optimizations to minimize queries and reduce bandwidth. Here are a few ideas:
  1. The List/Statuses query has SinceID/MaxID, which means you can do paging. Even more interesting is that keeping track of your SinceID for a User/List combination will keep you from reading tweets that you already have. So, when you get a tweet for that user/person, you can save it and optimize with SinceID.
  2. Looping sounds like it performs worse than a lookup. Once you have statusList, you might be able to build a key to do a ToDictionary or ToLookup and then do a query off the cached dictionary. This would depend on how current you want tweets and your performance/memory trade-off.
I'm not sure what application you're building, but another possibility is to run a UserStream on behalf of each user. This gives you their tweets in real-time. Then just do a query on their timeline if the stream temporarily stops or needs to be restarted. You can still use the list to query user IDs of the members with a List/Members query.

Dec 21, 2013 at 5:21 PM
Edited Dec 21, 2013 at 7:46 PM
Thanks Joe, very helpful -

I was aware of the "SinceID" param, just left it out for clarity at this point. For context the app's basic structure on Twitter is like this:
                5 to 30 members
but scaling lives at the ListOwnerAccount level depending upon the App's success - so that structure could be repeated anywhere from 10 to ?? times.

Given that, the UserSteam option sounds promising and I have looked up the documentation for a multiple user stream
here (also below) and have had a look at the corresponding Demo.
            Console.WriteLine("\nStreamed Content: \n");
            int count = 0;
            (from strm in twitterCtx.UserStream
             where strm.Type == UserStreamType.Site &&
                   //strm.With == "followings" &&
                   strm.Follow == "15411837"//,16761255"
             select strm)
            .StreamingCallback(strm =>
                Console.WriteLine(strm.Content + "\n");
                if (count++ >= 10)
For clarification I looked for the 'UserStream' Entity in the documentation but could come up with it. Can you point me?

All your work and any guidance very much appreciated!