I've seen so many Wordpress blogs that have nicely styled number of RSS subscribers and Twitter followers, but almost none ASP.NET-based blog engines. I am still using a default RSS subscriber counter provided by Feedburner which is, let's face it, ugly and boring, but that will change soon. Here is a simple and quick way to get your numbers in ASP.NET
RSS Subscribers
You can use FeedBurner Awereness API to get all the information you need. By calling the URL below and passing your FeedBurner username, you will get the an XML document with some information.
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=jankoatwarpspeed");
This document looks like the exemple below. Circulation attribute of entry element is actuall number of your followers.
<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok">
<feed id="4phmc8tprfr2ev14294rmu32d4" uri="JankoAtWarpSpeed">
<entry date="2009-11-23" circulation="6313" hits="17152" downloads="0" reach="147" />
</feed>
</rsp>
So, to get this number, just find all entry elements, get the first one (and the only one), and read its circulation attribute.
XmlNodeList subscribers = xmlDoc.GetElementsByTagName("entry");
Response.Write(subscribers[0].Attributes["circulation"].Value);
Twitter followers
Similar to previous example, you can get needed information in XML format using Twitter API. A list of your followers is located in ids.xml. Results returned from API will look like the code below.
<?xml version="1.0" encoding="UTF-8"?>
<id_list>
<ids>
<id>30592818</id>
<id>21249843</id>
... truncated ...
</ids>
...
</id_list>
Logically, all you have to do is to count the number of id's in the list.
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("http://twitter.com/followers/ids.xml?screen_name=jankowarpspeed");
XmlNodeList twitterList = xmlDoc.GetElementsByTagName("id");
Response.Write(twitterList.Count.ToString());
Conclusion
Normally you wouldn't use response.write and you might consider doing this with LINQ, but you got the point. So, BlogEngine users (including myself) and others, no more excuses for that ugly counters.
Janko is a UI designer, software engineer, blogger, speaker and artist. You can read more about him and warp speed blog here.