我試圖創建一個使用Python的xmpppy超過Facebook的聊天消息發送一個非常簡單的腳本。xmpppy和Facebook聊天集成
import xmpp FACEBOOK_ID = "[email protected]" PASS = "password" SERVER = "chat.facebook.com" jid=xmpp.protocol.JID(FACEBOOK_ID) C=xmpp.Client(jid.getDomain(),debug=[]) if not C.connect((SERVER,5222)): raise IOError('Can not connect to server.') if not C.auth(jid.getNode(),PASS): raise IOError('Can not auth with server.') C.send(xmpp.protocol.Message("[email protected]","Hello world",))
此代碼通過Google即時通訊發送消息,但是當我嘗試用facebook我收到此錯誤:
在查找出錯_xmpp-client._tcp.chat.facebook.com
當我從FACEBOOK_ID刪除@ chat.facebook.com我得到這個代替:
File "gtalktest.py", line 11, in if not C.connect((SERVER,5222)): File "/home/john/xmpppy-0.3.1/xmpp/client.py", line 195, in connect if not CommonClient.connect(self,server,proxy,secure,use_srv) or secureNone and not secure: return self.connected File "/home/john/xmpppy-0.3.1/xmpp/client.py", line 179, in connect if not self.Process(1): return File "/home/john/xmpppy-0.3.1/xmpp/dispatcher.py", line 302, in dispatch handler['func'](session,stanza) File "/home/john/xmpppy-0.3.1/xmpp/dispatcher.py", line 214, in streamErrorHandler raise exc((name,text)) xmpp.protocol.HostUnknown: (u'host-unknown', '')
我也注意到任何時候我導入XMPP我碰到下面當r兩個消息unning:
/home/john/xmpppy-0.3.1/xmpp/auth.py:24: DeprecationWarning: the sha module is deprecated; use the hashlib module instead import sha,base64,random,dispatcher /home/john/xmpppy-0.3.1/xmpp/auth.py:26: DeprecationWarning: the md5 module is deprecated; use hashlib instead import md5
我是相當新的解決這類問題,並建議,或資源的鏈接,可以幫助我前進中解決這些問題,將不勝感激。謝謝閱讀!
看起來你是在一個正確的方式做所有。嘗試將`always`添加到Client構造函數的`debug`參數中:`C = xmpp.Client(jid.getDomain(),debug = ['always'])``。也許這些日誌會說多一點。 :) – eigenein 2011-01-19 09:32:21