2

I am trying to figure out how to make Strophe.js work with the XEP-0055 plugin. So I guess I first have to determine what search fields are supported by the service, then I have to send the actual request:

<iq type='set'
    from='romeo@montague.net/home'
    to='characters.shakespeare.lit'
    id='search2'
    xml:lang='en'>
  <query xmlns='jabber:iq:search'>
    <last>Capulet</last>
  </query>
</iq>

But how do you translate it into Strophe.js query? This is my attempt:

$iq({to: 'characters.shakespeare.lit', 
from: 'romeo@montague.net/home', 
type: 'set', 
id: 'search2'}).c('query', {xmlns: 'jabber:iq:search'}).t("last", search_query)

and what exactly do I need to send, eg

to: characters.shakespeare.lit - is is the address of the XMPP service I am using? eg. jabber.org

from: romeo@montague.net/home - is it my ID on the server?

4

1 回答 1

2
    var iq = $iq({
          type: 'set',
          id: 'search2',
          to: 'vjud.yourserver.org'
    })
.c('query', {xmlns: 'jabber:iq:search'})
.c('x', {xmlns: 'jabber:x:data', type:'submit'})
.c('field', {var: 'first'}).c('value','Rub*').up(); 
conn.sendIQ(iq);

注意:至:characters.shakespeare.lit

不是您的服务器,而是 vcard 服务搜索。

.c('field', {var: 'first'})如果有任何错误将 var 更改为 'var'

于 2013-10-14T02:09:40.557 回答