Windows Live Messenger + Twitter Addin (with setup and source code)

Twitter is a free social networking and micro-blogging service that allows users to send "updates" (or "tweets" (TW); text-based posts, up to 140 characters long) to the Twitter website. [Source: wikipedia]

Being an user of MSN (ops, Windows Live Messenger) since many years now, I get used to keep my WLM Personal Message (PM)updated.

Now, if we think about the two technologies together, isn’t a tweet kind of a public version of our personal message? Yep smile_omg

Merge

For this reason, I’ve developed with my dear friends Stefano Santoro (Microsoft Student Partner from Italy) and Marco Bodoira (CE Embedded expert at BEPS) an add-in for Windows Live Messenger that keep the personal message of MSN synchronized with your Twitter status. Please note that this add-in is not supported. (More info about support below).

How does the add-in works?

When the add-in is turned on, it will keep your TW on Twitter synchronized with the PM on MSN; in fact your PM on MSN will be sent to TW within the specified polling time.

Addin 

Where can I download the add-in?

You can download the setup file here, or download and view the source code here.

How do I install the add-in?

In order to start the magic synchronization, you need to install the Setup file (download it here). On the first restart of WLM, you will be asked to prompt your Twitter information (obviously your information will be saved and you will not be prompted to insert them again…). The only action required from you is to manually Turn On the add-in.

TurnOn

Why did you developed this add-in?

For fun. smile_regular

To be used. lightbulb

To show some example of interoperability between “everyday application” and web services in the cloud. envelope

The whole communication layer with the Twitter web service uses web services, with the following two functions:

         internal bool SendTwitter(string message)
        {
            if (string.IsNullOrEmpty(message))
                return true;

            string auth = Convert.ToBase64String(Encoding.UTF8.GetBytes(Username + ":" + Password));
            string status = "status=" + HttpUtility.UrlEncode(message, Encoding.UTF8);
            byte[] data = Encoding.ASCII.GetBytes(status);

            try
            {
                HttpWebRequest req = WebRequest.Create(SetStatusUrl) as HttpWebRequest;
                req.Method = "POST";
                req.Headers.Add("Authorization", "Basic " + auth);
                req.ContentType = "application/x-www-form-urlencoded";
                req.ContentLength = data.Length;

                Stream reqStream = req.GetRequestStream();
                reqStream.Write(data, 0, data.Length);
                reqStream.Close();

                return true;
            }
            catch
            {
                return false;
            }
        }

        internal string GetTwitter()
        {
            string auth = Convert.ToBase64String(Encoding.UTF8.GetBytes(Username + ":" + Password));

            try
            {
                HttpWebRequest req = WebRequest.Create(string.Format(GetStatusUrl, Username)) as HttpWebRequest;
                req.Headers.Add("Authorization", "Basic " + auth);
                req.ContentType = "application/x-www-form-urlencoded";

                XmlTextReader reader = new XmlTextReader(req.GetResponse().GetResponseStream());
                string status = string.Empty;
                if (reader.ReadToDescendant("text"))
                    status = reader.ReadString();
                reader.Close();

                return status;
            }
            catch
            {
                return "";
            }
        }

An interesting bit of this project is the setup file, that performs the following operations:

  • Check pre-requisites
  • Deploy assembly and configuration file
  • Register assembly in the GAC
  • Instruct programmatically WLM to run add-ins
  • Instruct programmatically WLM to install our add-in
  • Complete rollback of the installation in case you want to uninstall...

Is the add-in supported?

NO, the add-in is not (and will not be) supported. However we tested it successfully on Windows XP 32bit (English and Italian), Windows Vista 32bit (English and Italian)…with Windows Live Messenger 8.5 and Windows Live Messenger 9.0. Please let us know if you can install it on platforms other than these.

Does the add-in need any 3rd-party components or Plus or will it ask me to pay?

NO, NO, NO. The add-in requires Windows Live Messenger and the .NET Framework 2.0 installed only. If the setup detects that you are missing the .Net Framework, it will download and install it automatically for you.

What are your Twitter account?

Want to know more about Windows Live Platform?

Have a look at those great blogs from colleagues:

Any feedback?

Please feel free to add a comment or a feedback to this post!

Thank you
Happy twittering with MSN,

Giorgio, Marco & Stefano

Technorati Tags: MSN,Windows Live Messenger,Twitter,C#,Addin,Installation