Twitter Utility: Is @X following @Y?

Occasionally I come across a situation where it would be interesting to know if a certain Twitter user is following some other Twitter user. I couldn’t find the right combo of search terms to find such a thing via Google or Bing, so I thought I’d just make one. Thanks to TweetSharp, it was incredibly easy. Here’s the ASP.NET MVC Controller code:

[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Check() {
    return View();
}
 
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Check(string follower, string target) {
    string response = FluentTwitter.CreateRequest()
                        .Friendships().Verify(follower).IsFriendsWith(target)
                        .Request();
 
    response = Regex.Replace(response, @"<\/?friends>", "");
 
    bool following = false;
    bool.TryParse(response, out following);
 
    return Json(new { result = following });
}

The view is a simple Spark file with some jQuery that posts to the Check() method above and displays the appropriate result based on the JSON returned.

Check it out and let me know what you think!

Posted August 29th, 2009 7:59 PM
Read more posts about ASP.NET MVC, Programming, Twitter.

Comments
Link

blog comments powered by Disqus