Is it possible to get the name of the currently authenticated user from the Google Talk XMPP API? I know that it's possible to get the name of your contacts by using this, but it doesn't return your name, just your contacts.

P.S. I'm using the node-xmpp module to connect with the API.

有帮助吗?

解决方案

You can request your own Vcard and get your name from the response when it was set before. See: http://xmpp.org/extensions/xep-0054.html

Example:

<iq id='get_vcard'        
    type='get'>
  <vCard xmlns='vcard-temp'/>
</iq>

<iq id='get_vcard'
    to='your_full_jid'
    type='result'>
  <vCard xmlns='vcard-temp'>
    <FN>Your Full Name</FN>
    <N>
      <FAMILY>Familiy Name</FAMILY>
      <GIVEN>Given Name</GIVEN>
      <MIDDLE/>
    </N>
    <NICKNAME>nickname</NICKNAME>
  </vCard>
</iq>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top