DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

How To Send IM Jabber Message To Google Chat Using Python And Xmppy

05.10.2007
| 11394 views |
  • submit to reddit
        // From http://www.franklinmint.fm/blog/archives/000603.html
// This works with version xmpppy-0.4.0.win32.exe from http://xmpppy.sourceforge.net/
import sys,xmpp

# Google Talk constants
FROM_GMAIL_ID = "user@gmail.com"
GMAIL_PASS = "password"
GTALK_SERVER = "talk.google.com"
TO_GMAIL_ID = "user@gmail.com"

jid=xmpp.protocol.JID(FROM_GMAIL_ID)
cl=xmpp.Client(jid.getDomain(),debug=[])
if not cl.connect((GTALK_SERVER,5222)):
    raise IOError('Can not connect to server.')
if not cl.auth(jid.getNode(),GMAIL_PASS):
    raise IOError('Can not auth with server.')

cl.send( xmpp.Message( "someone@gmail.com" ,"Hi" ) )
cl.disconnect()