Live Messenger API Status Icons

by Patrice 10/13/2008 10:43:21 PM

I just finished working on a small task where I wanted to use Live Messenger API in a web page (this allows the user to contact you using Messenger without having Messenger installed on his machine and having your contact set in it).  A friend of mine just did this for his business web site and I found it very useful. I decided to try it myself.

Since my friend has already done this, he guided me directly where I needed to go to learn about the API. After 10 minutes, it was done.  Basically, you just have to paste this (replace 1111111111111 by your user ID):

<a target="_blank" href="http://settings.messenger.live.com/Conversation/IMMe.aspx?
			invitee=1111111111111@apps.messenger.live.com&mkt=en-US">
    <img style="border-style:none;" src="http://messenger.services.live.com/users/1111111111111@
			apps.messenger.live.com/presenceimage?mkt=en-US" />
</a>

...and it returns this series of icons:

, , etc   ....they are small, just 16x16 and not "clean".

So what can I  do? After investigating, I found that I can get the status by two ways (1111111111111 is your user ID):

1- http://messenger.services.live.com/users/1111111111111@apps.messenger.live.com/presenceimage?mkt=en-US

...that will redirect to the status gif image.

2 - http://messenger.services.live.com/users/1111111111111@apps.messenger.live.com/presence?mkt=en-US

...that will return the status information in JSON format.

One thing I didn't want is use JavaScript. Obviously, if that wouldn't have been the case, JSON would have been the best choice here and easily implemented.

So I had to do the job from the server. I was looking for the easiest way so I just called ".../presenceimage?", using HttpWebRequest and just replaced "live.com" link by my server path... easy!

using (WebResponse response = request.GetResponse())
{
    string msnpath = response.ResponseUri.AbsolutePath;
    localImg += msnpath.Substring(msnpath.LastIndexOf("/") + 1);
}

Note that I don't download the image by calling GetResponseStream.

So by replacing the path, I obviously need to have the replacing image on my server. For that, I Googled a bit and found two set of icons that look much better. MSN Crystal Icons and Messenger Icon Pack... Just use your favorite image editor to resize then and/or change the format.

While I was there, I said "Well, why not a custom control?" To implement this I just rendered the a and img elements in a WebControl ... just few lines... look at the code if you are interested...  In the ASPX, it looks like this:

<lfdx:MSNMessenger uid="8a69c004ce9860b4" cssclass="wt" serverimgpath="images/" runat="server" />
  • uid is the Messenger user Id
  • cssclass class applied to a element
  • serverimgpath is the location of your custom images

Download the project here. Note that I have included the "Messenger Icon Pack" that I have resized to 30x30 gif images.

Nothing complex here just a fun project!

 

Powered by BlogEngine.NET 1.3.1.0

LFDX Software Inc.

About the author

P. Lafond Patrice Lafond
(and yes, it's Mr!)
Software Engineer
French Canadian expat in Bermuda for over 7 years.
flag QC  flag BDA

E-mail me Send mail

Calendar

<<  January 2009  >>
MoTuWeThFrSaSu
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

Pages

    Recent comments

    Authors

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2009

    Sign in