首页 > 代码库 > [Python]实现XMPP协议即时通讯发送消息功能

[Python]实现XMPP协议即时通讯发送消息功能

#-*- coding: utf-8 -*-__author__ = tsbcimport xmppimport time#注意帐号信息,必须加@域名格式from_user = chenjiangpeng@xtpt.e-u.cnpassword = a1b2c3d4#可以添加多个接收人to_user = [chenjiangpeng@xtpt.e-u.cn]msg = "您好!这是条测试信息!"def to_msg():"""基于xmpp协议的即时通讯消息发送,需求安装xmpp库使用openfire搭建的即时通讯都可以使用google talk也可以使用"""client = xmpp.Client(xtpt.e-u.cn)client.connect(server = (xtpt.e-u.cn, 5223))client.auth(from_user, password, botty)for i in to_user:client.sendInitPresence()message = xmpp.Message(i, msg, typ = chat)client.send(message)time.sleep(0.2)if __name__==__main__:to_msg()

 

[Python]实现XMPP协议即时通讯发送消息功能