Di python kita juga bisa kirim message ke user / friends via Google Talk atau messenger lain yang berbasis XMPP ( Jabberd, openfire, Ejabberd). Scriptnya cukup sederhana. Sample ini gua udah test lewat google dan Openfire dikantor
Download / install dulu packagenya
sudo apt-get install python-xmpp
Kemudian ketik
nano test01.py
isi dengan
FROM_JABBER_ID = "myname@openfire"
JABBER_PASS = "123456"
JABBER_PORT = "52222"
JABBER_SERVER = "IPserver_openfire_jabber"
TO_JABBER_ID = "friends@openfire"
jid=xmpp.protocol.JID(FROM_JABBER_ID)
cl=xmpp.Client(jid.getDomain(),debug=[])
if not cl.connect((JABBER_SERVER,JABBER_PORT )):
raise IOError('Can not connect to server.')
if not cl.auth(jid.getNode(),JABBER_PASS):
raise IOError('Can not auth with server.')
cl.send( xmpp.Message( TO_JABBER_ID ,"Hello World again" ) )
cl.disconnect()
Kemudian run
python test.py
selesai
Download / install dulu packagenya
sudo apt-get install python-xmpp
Kemudian ketik
nano test01.py
isi dengan
FROM_JABBER_ID = "myname@openfire"
JABBER_PASS = "123456"
JABBER_PORT = "52222"
JABBER_SERVER = "IPserver_openfire_jabber"
TO_JABBER_ID = "friends@openfire"
jid=xmpp.protocol.JID(FROM_JABBER_ID)
cl=xmpp.Client(jid.getDomain(),debug=[])
if not cl.connect((JABBER_SERVER,JABBER_PORT )):
raise IOError('Can not connect to server.')
if not cl.auth(jid.getNode(),JABBER_PASS):
raise IOError('Can not auth with server.')
cl.send( xmpp.Message( TO_JABBER_ID ,"Hello World again" ) )
cl.disconnect()
Kemudian run
python test.py
selesai
Powered by ScribeFire.
Tidak ada komentar:
Posting Komentar