Question

I'm beginner in XMPP. I'm using Strophe js library.

Now I wondering to get a specific roster item by its jabber id.

But I'm confused about what kind of stanza & property that I need to send.

I've got the way to retrieve my roster list by sending IQ stanza like this:

<iq from='juliet@example.com/balcony'
       id='bv1bs71f'
       type='get'>
    <query xmlns='jabber:iq:roster'/>
</iq>

But I got all contact list like this:

<iq id='bv1bs71f'
       to='juliet@example.com/chamber'
       type='result'>
    <query xmlns='jabber:iq:roster' ver='ver7'>
      <item jid='nurse@example.com' name='Nurse'/>
      <item jid='romeo@example.net' name='Romeo'/>
      <item jid='abc@example.net' name='Abc'/>
      ....
    </query>
</iq>

My question is how to get the specific item (only one item result) by sending my contact JID as a parameter?

If I could explain by SQL the statement is like this:

SELECT * FROM roster WHERE jabberID = ....

rather than this:

SELECT * FROM roster

I want to get my contact nickname by its JID.

Thanks in advance :)

Was it helpful?

Solution

Just add a "to" attribute in your iq. If you are co-subscribed, should return name.

$iq({ type: 'get', from: myjid, to: jid }).c('query', { xmlns: Strophe.NS.ROSTER });

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