在 Facebook 聊天中获取用户 ID 而不是用户名

发布于 2024-10-31 03:42:44 字数 666 浏览 1 评论 0 原文

我可以使用 Smack 集成 Facebook 聊天。我得到了我的朋友列表,但都是他们的用户 ID,而不是他们的名字。

以下是获取好友列表的代码

public void displayBuddyList()
{

    Roster roster = connection.getRoster();
    Collection<RosterEntry> entries = roster.getEntries();

    System.out.println("\n\n" + entries.size() + " buddy(ies):");

    for(RosterEntry r:entries)
    {
      System.out.println(r.getUser());
    }

。Gtalk 的相同代码给出了姓名。 http://developers.facebook.com 上没有提及它。

如何将名册视图设置为使用名称而不是用户 ID?

有没有办法检索名称而不是用户 ID?

I could integrate Facebook chat using Smack. I get my friends list but it's all their user id's and not their names.

The following is the code for getting friends list

public void displayBuddyList()
{

    Roster roster = connection.getRoster();
    Collection<RosterEntry> entries = roster.getEntries();

    System.out.println("\n\n" + entries.size() + " buddy(ies):");

    for(RosterEntry r:entries)
    {
      System.out.println(r.getUser());
    }

The same code for Gtalk gives the names.
There's no mention of it on the http://developers.facebook.com.

How to I set my roster view to use names instead of user id's?

Is there any way to retrieve the names instead of user id's?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

征棹 2024-11-07 03:42:44
  1. 您的问题标题似乎与正文内容相反 - 在 facebook 聊天中获取用户 ID 而不是用户名

  2. 请花时间输入完整的单词和连贯的句子并格式化您的问题 - 这表明您愿意投入努力提问,这使得有人更有可能努力回答。它还可以让您更轻松地理解您要问的内容。我必须读你的问题 5 遍才能浏览所有...和???并弄清楚您遇到的问题是什么。

  3. 回答您的问题 - RosterEntry#getName() 如查看文档所示。

    for(RosterEntry r:entries)
    {
        System.out.println(r.getName());
    }
    
  1. Your question title seems to be the opposite of what the body says - Getting user id s instead of user names in facebook chat

  2. Please take the time to type out complete words and coherent sentences and format your question - it show that you're willing to put in effort in asking which makes it more likely someone will put in the effort to answer. It also makes it easier to understand what it is you're asking. I had to read your question 5 times before I was able to navigate my way through all the ... and ??? and figure out what it was that you were having trouble with.

  3. To answer your question - RosterEntry#getName() as a look at the documentation would have shown.

    for(RosterEntry r:entries)
    {
        System.out.println(r.getName());
    }
    
罪歌 2024-11-07 03:42:44

您可以尝试以下

    // Get the user's roster
    Roster roster = connection.getRoster();

    // Print the number of contacts
    for(RosterEntry entry:roster.getEntries()){
        System.out.println(entry.getName());
    }

另请参阅

You can try following

    // Get the user's roster
    Roster roster = connection.getRoster();

    // Print the number of contacts
    for(RosterEntry entry:roster.getEntries()){
        System.out.println(entry.getName());
    }

See Also

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文