here you will run into problems.... basically you can write a standalone php application that can do anything a c/c++ apllication can do ( in principle )
but your webserver will create a new instance of php when the page request is made, and after it's done processing the page, it will kill the php process, so your im conversation would have to take place only for the page load < 1 sec mostly.
if you keep track of the usename and password for each user logged in you could log onto AIM post the message, then log off again, but i don't think that would work...
if you want you could write a holder application... a c daemon or php chat daemon that runs in the backgroud, is always running and listens for the asynchronous requests from the php started in the webserver, it could then keep the connection live while waiting for new requests...
how does that grab you