Вопрос

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