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

#-*- coding: utf-8 -*-
__author__ = tsbc
import xmpp
import time
#注意帐号信息,必须加@域名格式
from_user = chenjiangpeng@xtpt.e-u.cn
password = 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()

 

文章来自:http://www.cnblogs.com/tsbc/p/4175199.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3