Getting jabber:iq:last with xmpppy

georgeencina at georgeencina at
Mon Apr 7 08:43:01 CEST 2008

I'm trying to do the following with the xmpppy library:
- log on to the google jabber server
- get idle time of one specific person on my roster.

Idle time means the values of jabber:iq:last.

When I do this in pidgin with the xmpp console open, I get the
following conversation:

<iq type='get' id='purpleb22cf798' to='other.person at
	<query xmlns='jabber:iq:last'/>

(other person)
<iq type='result' id='purpleb22cf798' to='georgeencina at
GaimA9B7F02F' from='other.person at'>
	<query xmlns='jabber:iq:last' seconds='126517'/>

Now, I'd like to do the same in python.
I'm logged in to the server with the following code.

import xmpp
login = 'georgeencina' #
pwd = 'secret'
cnx = xmpp.Client('')
cnx.connect( server=('',5223) )
cnx.auth(login,pwd, 'idlewatcher')

What would be the next step? I saw there is an xmpp.Iq class, which I
suppose is what I need to work with to construct the message I
observed in Pidgin.

Does anyone have some quick lines of code on how to construct and send
the message, and how to receive the response?


More information about the Python-list mailing list