What better way to list people I'm following

Jun 30, 2009 at 5:51 PM
I would like to list all users that I am following: ID, User Name.
thanks
Coordinator
Jun 30, 2009 at 7:04 PM

The people you are following are referred to as Friends in the API. Here's an example:

             var users =
                from tweet in twitterCtx.User
                where tweet.Type == UserType.Friends &&
                      tweet.ID == "15411837" // <-- user to get friends for (your user ID)
                select tweet;

            foreach (var user in users)
            {
                var status = user.Protected ? "Status Unavailable" : user.Status.Text;

                Console.WriteLine(
                        "ID: {0}, Name: {1}\nLast Tweet: {2}\n",
                        user.ID, user.Name, status);
            }

Joe

Jun 30, 2009 at 7:51 PM
Edited Jun 30, 2009 at 8:16 PM

Hi Joe,

 var twitterCtx = new TwitterContext("myuser","mypass");
    
    var users =
                from tweet in twitterCtx.User
                where tweet.Type == UserType.Friends &&
                 tweet.ID == twitterCtx.ID ??? /// Instantiates the class when he did not get the ID?
                select tweet;

1) It can automatically get my ID?
2) Is there way to get my ID?

thanks!

Coordinator
Jun 30, 2009 at 8:33 PM
Edited Jun 30, 2009 at 8:34 PM

TwitterContext doesn't have an ID property, but you could use UserName, like this:

             var users =
                from tweet in twitterCtx.User
                where tweet.Type == UserType.Friends &&
                      tweet.ID == twitterCtx.UserName
                select tweet;

The UserName property is set either manually or via the TwitterContext constructor that takes a user name and password.

Joe

Jun 30, 2009 at 9:29 PM
Edited Jun 30, 2009 at 10:39 PM

It worked.
Thanks!!

Jun 30, 2009 at 11:33 PM
There is something special in the use of SocialGraph?

         var friends =
                from friend in twitterCtx.SocialGraph
                where friend.Type == SocialGraphType.Friends              
                select friend;

tks!

Coordinator
Jul 1, 2009 at 2:13 PM

The ID defaults to the currently logged in user.

Joe

Jul 1, 2009 at 5:46 PM
If you run the above query is exactly as you have the error below
"You must specify either ID, UserID, or ScreenName."
tks
Coordinator
Jul 1, 2009 at 6:38 PM
Edited Jul 1, 2009 at 6:38 PM

Sorry, it worked without ID, UserID, and ScreenName at one time but the Twitter API changed.  As the error says, you need to supply one of those values, like this:

            var friends =
                from friend in twitterCtx.SocialGraph
                where friend.Type == SocialGraphType.Friends &&
                      friend.ScreenName == "JoeMayo"
                select friend;

Joe