0

我正在尝试使用 Strophe 从 ejabberd 服务器检索消息集合。我使用查询:

$iq({type: 'get'}).c('retrieve', {xmlns: 'http://www.xmpp.org/extensions/xep-0136.html#ns', with:'pivo@localhost/local',  start: '2012-10-28T17:38:00.000000Z'}).c('set', {xmlns: 'http://jabber.org/protocol/rsm'}).c('max').t('100');

这将为我生成以下 XMPP 数据包:

<iq type='get' xmlns='jabber:client'>
    <retrieve xmlns='http://www.xmpp.org/extensions/xep-0136.html#ns' with='pivo@localhost/local' start='2012-10-28T17:38:00.000000Z'>
        <set xmlns='http://jabber.org/protocol/rsm'>
            <max>100</max>
        </set>
    </retrieve>
</iq> 

但问题是服务器没有成功回复,他返回给我内部服务器错误。

如果我查看 Postgres 日志,我会发现以下错误:

**ERROR:  date/time field value out of range: "0000-01-01 00:00:00" at character 68**

我正在使用 ejabberd 2.1.10、pgsql 9.1。

有人可以帮我吗?

4

1 回答 1

2

首先你必须检查这个集合是否存在。你可以这样做:

<iq type='get' id='123456'>
  <list xmlns='http://www.xmpp.org/extensions/xep-0136.html#ns'
        with='jabbar@localhost'>
    <set xmlns='http://jabber.org/protocol/rsm'>
      <max>30</max>/*max number of collection that you want to retrieve*/ 
    </set>
  </list>
</iq>

来自 ejabberd 的回应:

<iq xmlns='jabber:client'
    from='root@localhost'
    to='root@localhost/24975890851351278205927376'
    id='123456'
    type='result'>
<list xmlns='http://www.xmpp.org/extensions/xep-0136.html#ns'>
<chat with='jabbar@localhost/2021512663135182487476431'
      start='2012-10-24T13:45:17.000000Z'/>
<chat with='jabbar@localhost/9286394041351135710472543'
      start='2012-10-25T20:09:13.000000Z'/>
<chat with='jabbar@localhost/9286394041351135710472543'
      start='2012-10-25T21:22:13.000000Z'/>/****** I will retrieve this *****/
<chat with='jabbar@localhost/9286394041351135710472543'
      start='2012-10-25T22:05:13.000000Z'/>
<chat with='jabbar@localhost'
      start='2012-10-25T23:03:14.000000Z'/>
<chat with='jabbar@localhost'
      start='2012-10-25T23:35:37.000000Z'/>
<set xmlns='http://jabber.org/protocol/rsm'>
<first index='0'>
63518305517@1
</first>
<last>
63518427337@15
</last>
<changed>
2012-10-25T23:37:21.000000Z
</changed>
<count>
6
</count>
</set>
</list>
</iq>

现在要从集合中检索消息,您必须在请求节中准确输入“start”和“with”:

<iq type='get' id='433534536'>
  <retrieve xmlns='http://www.xmpp.org/extensions/xep-0136.html#ns'
            with='jabbar@localhost/9286394041351135710472543'
            start='2012-10-25T21:22:13.000000Z'>
    <set xmlns='http://jabber.org/protocol/rsm'>
      <max>100</max>
    </set>
  </retrieve>
</iq>

回复:

<iq xmlns='jabber:client'
    from='root@localhost'
    to='root@localhost/24975890851351278205927376'
    id='433534536'
    type='result'>
<chat with='jabbar@localhost/9286394041351135710472543'
      start='2012-10-25T21:22:13.000000Z'>
<from secs='0'>
<body>
dddddddddd
</body>
</from>
<from secs='1'>
<body>
dddddddd
</body>
</from>
<set xmlns='http://jabber.org/protocol/rsm'>
<first index='0'>
63518419333@103
</first>
<last>
63518419334@105
</last>
<changed>
2012-10-25T21:22:14.000000Z
</changed>
<count>
2
</count>
</set>
</chat>
</iq>
于 2012-10-30T11:43:10.927 回答