Maria
Maria

Reputation: 515

How can I send data using xmpppy?

How can I send data with xmpppy using this method: http://xmpp.org/extensions/xep-0047.html#send

I suppose I should use IBB class but have no idea how to do it. http://xmpppy.sourceforge.net/apidocs/

Upvotes: 2

Views: 768

Answers (2)

eanix
eanix

Reputation: 325

I think something like that:

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


client.OpenStream('123', '[email protected]/resource', output)

Upvotes: 0

Joe Hildebrand
Joe Hildebrand

Reputation: 10414

First, if you're on GoogleTalk, ensure that the sender is on the receiver's roster. Next, on the sender side:

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)

It doesn't matter what the stream ID is if you're not doing XEP-95/XEP-96 correctly first.

Upvotes: 1

Related Questions