This project has moved and is read-only. For the latest updates, please go here.

Check out if a user is following another user

Nov 13, 2012 at 5:35 AM

I posted a comment here a while back. I cannot make the code to check if a user is following another user. My "SubjectUser" is an authenticated user in my application. Take note that I can run other queries such as Update Status using linqtotwitter. Please let me know what I missed.

Nov 13, 2012 at 11:45 PM


I often miss comments outside of the Discussons forum and didn't see that one. What does your query look like?


Nov 14, 2012 at 12:57 AM

Hi Joe,

Thanks I'll take note of that and always post here in the Discussions forum.

The query:


from friend in twitterCtx.Friendship
                         where friend.Type == FriendshipType.Exists &&
                               friend.SubjectUser == username &&
                               friend.FollowingUser == following
                         select friend)

returns an error message "Sorry, that page does not exist" with an inner exception message of "The remote server returned an error: (404) Not Found."


I also tried this:

var friendship =
                       (from friend in twitterCtx.Friendship
                        where friend.Type == FriendshipType.Show &&
                              friend.SourceScreenName== username &&
                              friend.TargetScreenName == following
                        select friend)

And that one works but the friendship.IsFriend property is always false even though the "username" is already following the "following".

Nov 14, 2012 at 1:40 AM

I'm using the same entity type for multiple friendship queries, so fields are populated by context. It might help if you look at the downloadable source code, which has examples. Here's an example of FreindshipType.Show:

            var friendship =
                (from friend in twitterCtx.Friendship
                 where friend.Type == FriendshipType.Show &&
                       friend.SourceScreenName == "Linq2Tweeter" &&
                       friend.TargetScreenName == "JoeMayo"
                 select friend)

                "\nJoeMayo follows LinqToTweeter: " + 
                friendship.SourceRelationship.FollowedBy + 
                "\nLinqToTweeter follows JoeMayo: " +

Notice that I'm looking at FollowedBy properties of SourceRelationship/TargetRelationship properties.

FriendshipType.Exists is deprecated in Twitter API v1.1, which is the reason for the 404 Not Found. I've just removed it from LINQ to Twitter. Thanks for letting me know.



Nov 14, 2012 at 4:30 AM

Ok great this works and thanks for removing the link on how to checkout friendship details :)

I am thinking, do we still need the Friendship.IsFriend? Maybe we can delete that to lessen confusion? Unless it has some other use.

Nov 14, 2012 at 12:58 PM

Good to hear. I agree and IsFriend will be removed too.


Nov 16, 2012 at 1:29 AM

Cool thanks Joe!