如何使用xmppy发送数据?

2024-05-23 15:26:08 发布

您现在位置:Python中文网/ 问答频道 /正文

如何使用xmppy方法发送数据:http://xmpp.org/extensions/xep-0047.html#send

我想我应该使用IBB类,但不知道怎么做。http://xmpppy.sourceforge.net/apidocs/


Tags: 方法orgsendhttpnethtmlxmppextensions
2条回答

我想是这样的:

import StringIO
...
output = StringIO.StringIO()
output.write('String data')
output.close()


client.OpenStream('123', 'receiver@example.com/resource', output)

首先,如果你在GoogleTalk上,确保发送者在接收者的名单上。接下来,在发送方:

from xmpp import *
cl=Client('example.com')
cl.connect()
cl.auth('sender', 'sender_pass')
ibb = filetransfer.IBB()
ibb.PlugIn(cl)

f = open('/tmp/foo')
ibb.OpenStream('123', 'receiver@example.com/resource', f)

如果您没有首先正确地执行XEP-95/XEP-96,那么流ID是什么并不重要。在

相关问题 更多 >