Question

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?

Was it helpful?

Solution

    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);

note: to: characters.shakespeare.lit

Not your server but the vcard service search.

.c('field', {var: 'first'}) if any error change var to 'var'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top