我必须发送基于xmpp的聊天客户端(hipchat),为此我使用xmpp.py。现在,我尝试从shell发送消息。下面是我在shell中执行的语句:
>>> import xmpp
>>> jid = xmpp.protocol.JID('99999_9999@chat.hipchat.com')
>>> cl=xmpp.Client(jid.getDomain(),debug=[])
>>> cl.connect()
'tls'
>>> cl.auth(jid.getNode(),'password')
'sasl'
>>> cl.send(xmpp.protocol.Message('99999_9999@chat.hipchat.com','hey!'))
'3'我使用相同的jabber id进行身份验证和作为接收者。我也在聊天室里,但是我没有收到任何消息。遗漏了什么?
发布于 2012-06-28 18:27:57
我缺少typ参数。给它加上值chat就解决了这个问题:
cl.send(xmpp.protocol.Message('99999_9999@chat.hipchat.com','hey!', typ='chat'))发布于 2012-06-26 16:57:08
一些较旧的XMPP服务器需要初始在线状态。状态是在cl.send之前使用以下调用发送的
cl.SendInitPresence(requestRoster=0)另请参阅xmpppy主页上的xsend示例:http://xmpppy.sourceforge.net/examples/xsend.py
https://stackoverflow.com/questions/11202959
复制相似问题