2012-07-10 36 views
2

我怎样才能发送数据与xmpppy使用这种方法:http://xmpp.org/extensions/xep-0047.html#send如何使用xmpppy发送数据?

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

+0

不,这不是标准的消息是数据,应该由其他方式发送。 http://xmpp.org/extensions/xep-0047.html#send – Maria 2012-07-10 09:37:23

+0

你能从更广义的角度描述你的目标吗? – 2012-07-10 09:39:16

+0

我已经清除你的问题 - base64在旁边 – 2012-07-10 09:49:51

回答

1

首先,如果您使用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', '[email protected]/resource', f) 

不要紧流ID是什么,如果你不这样做XEP-95/XEP-96先正确。

+0

如果我不想从文件发送数据,该怎么办?如果它只是一组数字或字符串?我应该先将它们写入文件还是有另一种方式? – Maria 2012-07-11 09:13:49

0

我觉得这样的事情:

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


client.OpenStream('123', '[email protected]/resource', output) 
相关问题