Search code examples
pythonxmppxmpppy

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/


Solution

  • 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.