Get more informations with the friend timeline query

Apr 25, 2011 at 6:25 PM
Edited Apr 25, 2011 at 6:27 PM

Hi,

 

I'm currently making an application using linq2twitter. I handled the first steps without difficulties.

Authentication is doing well, the querying as well.

But now i'd like to display tweets in a gridview :

 

context = new TwitterContext(auth);

            TweetCollection collection = new TweetCollection();
            var tweets = from tweet in context.Status where tweet.Type == StatusType.Friends select tweet;
            foreach (var tweet in tweets)
            {
                DisplayedTweetModel model = new DisplayedTweetModel();
                model.userID = tweet.User.UserID;
                model.statusID = tweet.StatusID;
                model.imgUrl = tweet.User.ProfileImageUrl;
                model.screenName = tweet.User.ScreenName;
                model.createdAt = tweet.CreatedAt;
                model.text = tweet.Text;
                collection.addTweet(model);
            }

            GridView1.DataSource = collection.getListTweet();
            GridView1.DataBind();

 

The class DisaplayedTweetModel is from my own and TweetCollection is another classe I created that contains an IList containing tweets.

I need UserID and ScreenName data for each tweet but they are empty. If I use tweets as Datasource same thing, no UserID and ScreenName data.

 

Resume :

tweet.User.UserID and tweet.User.ScreenName are empty

Apr 26, 2011 at 10:49 AM

I changed my code, using a second query. As I explained with the friend timeline query userID, ID and ScreenName are empty, then I'm using a second query to get these information using the StatusID to extract the user and his information.

 

TweetCollection collection = new TweetCollection();
            var tweets = from tweet in context.Status where tweet.Type == StatusType.Friends select tweet;
            foreach (var row in tweets)
            {
                DisplayedTweetModel model = new DisplayedTweetModel();
                model.statusID = row.StatusID;
                var users = from tweet in context.User where tweet.Type == UserType.Show && tweet.Status.StatusID == model.statusID select tweet;
                var user = users.SingleOrDefault(); 
                model.userID = user.UserID;
                
                model.imgUrl = row.User.ProfileImageUrl;
                model.screenName = user.ScreenName;
                model.createdAt = row.CreatedAt;
                model.text = row.Text;
                collection.addTweet(model);
            }

            ListView1.DataSource = collection.getListTweet();
            //ListView1.DataSource = tweets;
            ListView1.DataBind();

But this second case doesn't work too. The reason is simple ID, UserID or ScreenName is requeried, we can't make a research without. Information I'm trying to get. Is there a way to get these information?

Apr 26, 2011 at 1:02 PM

Ok they are into user.Identifier.ScreenName, sorry...