MSN Messenger class

by Naneau

MSN Messenger is one of those things I wish I could abandon. But I can’t. In the Netherlands, it’s the number one instant messenger. And because I rather like the concept of having friends, I need to keep in touch with people. MSN Messenger is the way to go, unfortunately.

I like linux, I love gnome, but I can’t stand Pidgin (formerly GAIM). I really don’t know why. It’s interface is nice and uncluttered. It’s easy to use, yet it doesn’t feel the same. Of course, it’s support for MSN’s protocol is limited at best. Offline messages are still unsupported. That’s why I often find myself in Windows.

Anyway. I had a look around the web for a simple way of retrieving MSN Messenger contacts from php and found pretty much nothing. There are a few paid services that provide that service, which I think is an enormous rip-off. The free ones were in poor shape and usually lacked any useful documentation. Phpclasses strikes again! :( Blobsy seems nice, but a bit too complicated for my needs.

I decided to write my own implementation. While the protocol (I based it on version 8 ) is easy enough to understand, getting it to work proved a little difficult. Because it needs a https connection to log into MS passport I had to enable mod_ssl. It took me a full hour to find out there were some old dlls from a previous install left in my windows directory. Adding your php directory to your path really does make sense ;) .

I used a component from the Zend Framework to make life a little easier for me. If you’re planning on using it away from it, be sure to make Zend_Http_Client available in your include path. Go ahead and check out the demo and download Naneau MSN 0.1.

It is easy to use:

1
2
3
4
5
6
7
8
9
$msn = new Naneau_MSN_Messenger('email', 'password');
//create a new instance
//will also connect
//if you want to connect yourself, pass false as a third param
$contactList = $msn->getContactList();
//get the contact list, it implements iterator, so you can do:
foreach($contactList as $contact) {
    echo $contact->displayName . ': ' . $contact->email;
}