Using the Twitter REST API and Json.NET to see who doesn't follow you back on Twitter

by Heathesh 3. February 2012 05:09

 

I prefer following people that follow me back on twitter. So I normally check http://www.friendorfollow.com/ and generally unfollow people that aren't following me. While digging around the twitter dev site I found the REST APIs and I wanted to see what I could do with them. I figured a little console app that showed me who isn't following me back might be a decent challenge so I set off creating one.

I normally post step by step instructions of what I did in my blog posts, however this time I'm included the source code of the app so people can do whatever they want with it and I'm going to give you a basic run down of how the app works. You can download it here: http://heathesh.com/code/csharp/TwitterFollowerTest.zip

To begin with, I used the Twitter REST API to get a Json dataset of all the people I follow and all the people following me (I created a setting called "UserToCheck" in the app.config file so you can simply change this to any twitter handle to run the check for that account). I used Json.NET (http://james.newtonking.com/projects/json-net.aspx) to parse this Json into a simple list of user ids for each of the above. Then I simply iterated through the list and for anybody who wasn't following me I used another Twitter REST API call to get back that user's details in another Json dataset.

In order to make the user's detail more "user friendly" I created a simple class called TwitterUser and using the "DescriptionAttribute", reflection and Json.NET I populated this object with the Json dataset. Then I simply write out each screen name of whomever is not following me but from the code you will see you have a fully populated TwitterUser object which you could do quite a bit with (like display their twitter pic, bio etc.).

I'm pretty sure the code is pretty self-explanatory, but as usual if you have any questions feel free to contact me using my Contact page (http://heathesh.com/contact.aspx).

Happy tweeting!

 

Tags: , , , , , ,

Development | .Net

Comments are closed



Powered by BlogEngine.NET 1.5.0.7 (with enhancements by Heathesh)
Theme by Mads Kristensen (with tweeks by Heathesh)

Certifications

Microsoft Certified Professional

Microsoft Certified Technology Specialist

Answer Questions

 

Tag cloud

Calendar

<<  July 2017  >>
MoTuWeThFrSaSu
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

View posts in large calendar

http://heathesh.com