On Monday, September 10, 2001, at 08:47 AM, Nicolas Lafferty wrote:

I would like to write a PHP script to log on to a jabber server. Have the stored messages parsed to a web page. Then disconnect.

This doesn't actually make a lot of sense to me ... Jabber is a real-time, dynamic system, not like email. The idea is that you receive messages in real time, so the model is a continuous login session, not a single quick download as with POP.

I'm not really sure how to do this. I have been playing around with a PHP script that will connect and the send a message from a form. But the incoming messages is where my problem lies. I have looked into using expat (and xml parser) but i'm not sure if that will do it or not.

You definitely want to find an existing library that will do the XML parsing for you; parsing it yourself is not for the faint-hearted. I know almost nothing about PHP so I can't help you there. Hopefully someone has already written such a library.

expat is a C library with a C API so it would not help you from the PHP side.

I actually really need to know how to actually recieve the messages.....i think that is dont automatically at login. Any ideas would be very appreciated.

The server does queue up messages that are sent to you if you are not online, and it will deliver them to you as soon as you log in. After the login process you will receive <presence> elements from the server containing the messages. There is no way to know how many such messages are queued up, so the only thing to do is to open the connection and wait "a while" and hope you got them all. (Unless the server is really overloaded, you should receive them all within a second or two.)

However, as I said before, it seems unlikely that someone would send you an IM while you were offline. If I see someone's offline, I'm more likely to email them instead.

—Jens

Reply via email to