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; } |
Comments
I have to say, that is not so bad. In Czech republic, there is widely-used ICQ protocol. Worst protocol ever. It is like a plague, but You can not rid of it, because everyone is using it. Jabber rulez
I used to love ICQ. Before everybody got online, it was the only IM around. I spent many nights chatting with strangers from all over the world.
I don’t have a clue about it’s protocol though, might be interesting to find out. And create a set of classes to connect to all the major IM networks from ZF
You’ve probably already heard about it: aMSN. It’s interface is more cluttered and it looks ugly, but it supports a lot of the features of MSN (personal message, anyone?) and replicates the interface (what did I say about clutter?
)
http://www.amsn-project.net/
Yeah, I’ve heard about it. Used it even… I remember using it daily a few years back. But it really doesn’t work well with gnome, and I’m a integration nut on *nix, I want a coherent desktop. I like gaim, but it just lacks some things in the msn protocol. Makes me wish I could be bothered to (help) write desktop apps
[...] pagina del proyecto « ¿Qué es XSL? articulo introductorio a XSL. [...]
wow, thank you for the great post!
I was just thinking about if is it possible to join my arduino to msn protocol to send custom messages. This can be a good starting point (maybe with some Processing effort added). Can I ask you for a suggestion, please?
Thank you very much,
Marco & Luca
Nice article. Thank you.
I am looking for a PHP chat script to be integrated in my online game site and that support my registered users and ideally with some possible links to MSN and ICQ for the wide audiance. For the moment, I’ve not find the script of my dreams. Any suggestion, feel free to contact me.
Regards,
Alain
I am testing your class bit i have this error:
Fatal error: Uncaught exception ‘Exception’ with message ‘Not connected, can’t retrieve contact list’ in /Applications/MAMP/htdocs/MSN/Messenger.php:150 Stack trace: #0 /Applications/MAMP/htdocs/MSN/Messenger.php(386): Naneau_MSN_Messenger->getContactList() #1 {main} thrown in /Applications/MAMP/htdocs/MSN/Messenger.php on line 150
can you help me?
thanks