【问题标题】:XMPP transport to ICQXMPP 传输到 ICQ
【发布时间】:2015-01-14 12:21:57
【问题描述】:

我尝试通过 jabber-transport 向 icq 发送消息。我尝试使用此答案中的代码 XMPP transport to another protocol,但我收到了这条消息:

DEBUG -- : SENDING:
    <message to='12345@icq.jabber.blahblah.ru' xmlns='jabber:client'><body>test
 message from robot</body></message>
=> nil
DEBUG -- : RECEIVED:
    <message from='12345@icq.jabber.blahblah.ru' to='myjit@blahblah.ru/83076
14161416233482839674' type='error'><error code='401' type='auth'><not-authorized
 xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xmlns='urn:ietf:params:xml:n
s:xmpp-stanzas'>Error. You must log into the transport before sending messages.<
/text></error><body>test message from robot</body></message>

请解释一下:我做错了什么?提前致谢。

这是我的代码

require 'rubygems'
require 'xmpp4r/client'
include Jabber

Jabber.debug = true
jid = JID::new('myjit@blahblah.ru')
pass = 'pwd'
server = 'jabber.blahblah.ru'
port = '5223'
subj = 'Nagios notification'
user = '12345@icq.jabber.blahblah.ru'
text = 'AAAA AAAA AAAA'
cl = Jabber::Client::new(jid)
cl.use_ssl = true
cl.connect(server,port)
cl.auth(pass) 

#connect to transport
reg=Jabber::Iq.new_register "54321", "pwd2"
reg.to="icq.jabber.blahblah.ru"
cl.send reg

mes = Message::new(user,text)
cl.send(mes)
cl.close()

更新代码:

cl.connect(server,port)
cl.auth(pass)

# sending initial presence
p = Jabber::Presence.new
cl.send p

mes = Message::new(user,text)
mes.type = :chat

cl.send(mes)
cl.close()

返回:

D, [2014-11-18T19:01:35.986182 #8084] DEBUG -- : SENDING:
    <presence xmlns='jabber:client'/>
=> nil
irb(main):027:0> D, [2014-11-18T19:01:36.048980 #8084] DEBUG -- : RECEIVED:
    <presence from='icq.jabber.blahblah.ru' to='myjit@blahblah.ru' type='subscri
be'><status/></presence>

还是不行

【问题讨论】:

  • Transport 向您发送订阅请求,您应该批准它 (&lt;presence to='myjit@blablah.ru' type='subscribed' /&gt;),transport 将能够看到您的状态,并且如果需要,发送每个 icq 联系人的状态订阅,您需要批准也。事实上,你应该只在第一次这样做,并且可以使用任何现有的 xmpp 客户端。

标签: ruby xmpp transport xmpp4r icq


【解决方案1】:

您只需要第一次注册传输,然后您需要在会话创建后发送initial presence

【讨论】:

  • 你能写吗,在我的情况下,这个“初始存在”应该如何? (以 XML 为例)
猜你喜欢
  • 2012-01-23
  • 2011-05-16
  • 1970-01-01
  • 2014-06-29
  • 2013-01-18
  • 1970-01-01
  • 1970-01-01
  • 2013-01-16
  • 1970-01-01
相关资源
最近更新 更多