Not logged in. · Lost password · Register
Forum: XMPP Protocol RSS
Avatar
11alex11 #1
Subject: Cant get normal users name Instead I get negative Long number (via chat connect - Facebook)
I connect to facebook chat When I try to retrieve the list of online users I get their user names but in negative long number. Y is that? How can I get their normal names?

thanks :)
Avatar
Alex #2
The Facebook usernames are negative numbers. But the name is also submitted.

e.g.:
  1. <item subscription="both" name="Bob Brown" jid="-1111111@chat.facebook.com" />

Alex
Avatar
11alex11 #3
How do I write it in C#?

**I forgot to mention that I do all this things in c# (.net)
Avatar
Alex #4
which of our libraries are you using?

Alex
Avatar
11alex11 #5
I use this code
Avatar
Alex #6
You have to subscribe to the OnRosteritem event. Then use the follwing code to get the name.

  1. private void XmppCon_OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item)
  2. {
  3.     string name = item.Name;
  4. }
Avatar
11alex11 #7
It works :) thanks.

Can I connect between the name and the negative number? or between the Roster item and the Presence?
In Presence I have more functions to much to chat (status and etc'...)
Avatar
Alex #8
Quote by 11alex11:
Can I connect between the name and the negative number? or between the Roster item and the Presence?

yes, the name is only a user friendly description. You can populate a collection in the OnRosterItem event with the mapping Jid <--> name and look up them later when you need. The Jid is a unique identifier in XMPP. You get the Presence in the OnPresence event by Jid.

Alex
Avatar
11alex11 #9
thanks every thing works :)
Avatar
tal170 #10
11alex11

can you please post the code you used to match the jid to the name, im still having trouble figuring it out for some reason, thanks.
Avatar
11alex11 #11
        private void xmpp_OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item)
        {
            string itemName = item.Name;
            string itemJid = item.Jid.User;

            if (item.Name != null)
            {
                itemName.Replace('u', '-');
               
                nameLink.Add(new Names {jid = itemJid, name = itemName});

                _waitU = false;
                Console.WriteLine(" Got user List ");
            }
        }

nameLink is a list
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)