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='[email protected]/balcony'
id='bv1bs71f'
type='get'>
<query xmlns='jabber:iq:roster'/>
</iq>
But I got all contact list like this:
<iq id='bv1bs71f'
to='[email protected]/chamber'
type='result'>
<query xmlns='jabber:iq:roster' ver='ver7'>
<item jid='[email protected]' name='Nurse'/>
<item jid='[email protected]' name='Romeo'/>
<item jid='[email protected]' 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 :)
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 });