我怎樣才能發送數據與xmpppy使用這種方法:http://xmpp.org/extensions/xep-0047.html#send如何使用xmpppy發送數據?
我想我應該使用IBB類,但不知道該怎麼做。 http://xmpppy.sourceforge.net/apidocs/
我怎樣才能發送數據與xmpppy使用這種方法:http://xmpp.org/extensions/xep-0047.html#send如何使用xmpppy發送數據?
我想我應該使用IBB類,但不知道該怎麼做。 http://xmpppy.sourceforge.net/apidocs/
首先,如果您使用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)
如果我不想從文件發送數據,該怎麼辦?如果它只是一組數字或字符串?我應該先將它們寫入文件還是有另一種方式? – Maria 2012-07-11 09:13:49
我覺得這樣的事情:
import StringIO
...
output = StringIO.StringIO()
output.write('String data')
output.close()
client.OpenStream('123', '[email protected]/resource', output)
不,這不是標準的消息是數據,應該由其他方式發送。 http://xmpp.org/extensions/xep-0047.html#send – Maria 2012-07-10 09:37:23
你能從更廣義的角度描述你的目標嗎? – 2012-07-10 09:39:16
我已經清除你的問題 - base64在旁邊 – 2012-07-10 09:49:51