[英]Send a xmpp message using xmmp python library and google app engine
[英]Send an xmpp message using a python library
如何使用以下Python庫之一發送XMPP消息:wokkel,xmpppy或jabber.py?
我想我知道偽代碼,但到目前為止還沒能正確運行。 這是我到目前為止所嘗試的:
在概念上似乎很容易,但魔鬼在細節中的某個地方。 如果可能,請顯示示例代碼段。
這是最簡單的xmpp客戶端。 它會發送一個'hello :)'消息。 我在示例中使用了xmpppy
。 並連接到gtalk服務器。 我認為這個例子是不言自明的:
import xmpp
username = 'username'
passwd = 'password'
to='name@example.com'
msg='hello :)'
client = xmpp.Client('gmail.com')
client.connect(server=('talk.google.com',5223))
client.auth(username, passwd, 'botty')
client.sendInitPresence()
message = xmpp.Message(to, msg)
message.setAttr('type', 'chat')
client.send(message)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.