码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2014-12-20 12:52:31      阅读:551      评论:0      收藏:0      [点我收藏+]

标签:

#-*- 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()

 

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

标签:

原文地址:http://www.cnblogs.com/tsbc/p/4175199.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!