Playing with Twitter API - The RSS Blog
RSS, OPML and the XML platform.
Copyright 2012 World Readable
The RSS Blog
<< Previous Main Next >>
Mon, 03 Oct 2011 08:18:53 GMT
Playing with Twitter API

Yesterday, I did something fun and played with the twitter API. I was trying to reduce my twitter followings and want to purge all followings with no activity in the last month. With 900+ followings, that would be too much to hand manually, so automation to the rescue.

This required the use of 2 API calls.{0}{0}

One to load the list of my friends and the 2nd to turn that list of ids into user profiles. You can then check the creation date of the users status to get his last activity date.

Because of the REST XML API style, this was trivial to use. Not to mention the documentation on the website was better than adequate. I did find a few problems using the API.

Code follows

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)
            string s = string.Format("{0}", "talkSportscom");
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            if (!System.IO.File.Exists("ids.xml"))

            foreach (System.Xml.XmlElement e in doc.SelectNodes("//id"))
                    if (e.HasAttribute("done"))
                    e.SetAttribute("done", "true");

                    // need to sleep 30 seconds between calls to avoid 150 rate limit per hour
                    //System.Threading.Thread.Sleep(30 * 1000);

                    s = string.Format("{0}", e.InnerText);
                    System.Xml.XmlDocument d = new System.Xml.XmlDocument();


                    System.Xml.XmlElement dt = (System.Xml.XmlElement)d.SelectSingleNode("//status/created_at");
                    if (dt != null)
                        string dt2 = dt.InnerText;
                        dt2 = dt2.Substring(4, 6);
                        System.DateTime dateTime = Convert.ToDateTime(dt2);
                        if (System.DateTime.UtcNow.AddMonths(-1) < dateTime)

                    dt = (System.Xml.XmlElement)d.SelectSingleNode("//screen_name");

                    System.Diagnostics.Process.Start(string.Format("!/{0}", dt.InnerText));


Fun and task accomplished. Thanks twitter. I got rid of a few dozen twitter followings.

Reader Comments Subscribe
thanks for the code
Toronto News are full of an Apple store discount on black Friday. But it is not so big to talk about...
welcome to ( We are specialized in high quanlity jerseys we are wholesale NFL MLB NBA NHL Women Youth Jerseys $17 a pcs , free shipping any questions or needs are welcome ,we will endeavor to do best service for you. thanks in advance.
Type "339":
Top Articles
  1. Unblock MySpace
  2. MySpace
  3. FaceParty, the British MySpace
  4. and
  5. Blocking Facebook and MySpace
  1. Review of RSS Readers
  2. MySpace Layouts
  3. RSS Stock Ticker
  4. RSS Gets an Enema
  5. Google Reader rejects