As far as I am aware, you would have to communicate with the servers directly.
In other words, you would use
fsockopen() to establish a connection with the messaging server and the communicate from there.
For example, AIM's would be opening "login.oscar.aol.com" on port 5190.
As far as what needs to be sent, I do not know. You will need to research each instant messenger individually, which will take you a bit of time. Hopefully this will get you pointed into the right direction though.