How to verify if a twitter users is following a given user using REST API

This code sample will show how you can use Twitter REST API to verify if one twitter user is following a specified user or not. The use of this API is little tricky. It requires you to specify two screen names or IDs that you want to verify. There is Exists method on Friendships object in Tweetsharp API but it only takes one parameter. If you try to use the API just like that it will return error telling you that you need to specify two screen names or ids to verify. The use of this API is not very intutive. So I had to dig down into the code to figure out how it can be done. There is property VerifyScreenName on IFluentTwitterParameters. You have to set second screen name here. See how it is done in code below.

static void VerifyFriendShip(string screenName1, string screenName2)
 IFluentTwitter ft = FluentTwitter.CreateRequest();
 ft.AuthenticateAs(LOGIN_NAME, PASSWORD);
 ft.Parameters.VerifyScreenName = screenName2;
 var resp = ft.Request();
 if (null != resp)

Return value from this API is true or false.




22.3 °C / 72.2 °F

weather conditions Clouds

Monthly Posts

Blog Tags