Mobile Line Of Business

Richard Jones (MVP)

  Home  |   Contact  |   Syndication    |   Login
  202 Posts | 0 Stories | 36 Comments | 0 Trackbacks


Welcome to the Mobile Line Of Business Blog

Tag Cloud


Post Categories


So I blatantly got this idea from the MIX 10 event.

At MIX they held a rockband talent competition type thing (I’m not quite sure of all the details).    But the interesting part for me is how they collected votes.

They used Twitter (what else, when you have a few thousand geeks available to you).

The basic idea was that you tweeted your vote with a # tag, i.e

#ROCKBANDVOTE vote Richard

How cool….    So the question is how do you write something to collate and count all the votes?   Time to press the magic Visual Studio new Project button…

Twitter has a really nice API that can be invoked from .NET.  

This is the snippet of code that will search for any given phrase i.e #ROCKBANDVOTE


public static XmlDocument GetSearchResults(string searchfor)
            return GetSearchResults(searchfor, "");
        public static XmlDocument GetSearchResults(string searchfor, string sinceid)
            XmlDocument retdoc = new XmlDocument();
                string url = "" + searchfor;
                if (sinceid.Length > 0)
                    url += "since_id=" + sinceid;
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "POST";
                request.ContentType = "application/x-www-form-urlencoded";
                WebResponse res = request.GetResponse();
            return retdoc;

I’ve got two overloads, that optionally let you pass in the last ID to look for as well as what you want to search for.

Note that Twitter rate limits the amount of requests you can send,  see

So realistically I wanted my app to run every hour or so and only pull out results that haven’t been received before (hence the overload to pass in the sinceid parameter).

I’ll post the code when finished that parses the returned XML.

posted on Thursday, March 25, 2010 5:40 AM