PHPDaemon\Clients\XMPP\Connection::getVCard PHP Method

getVCard() public method

public getVCard ( string $jid, callable $cb )
$jid string
$cb callable
    public function getVCard($jid, $cb)
    {
        $id = $this->getId();
        $this->xml->addIdHandler($id, function ($xml) use($cb) {
            $vcard = [];
            $vcardXML = $xml->sub('vcard');
            foreach ($vcardXML->subs as $sub) {
                if ($sub->subs) {
                    $vcard[$sub->name] = [];
                    foreach ($sub->subs as $sub_child) {
                        $vcard[$sub->name][$sub_child->name] = $sub_child->data;
                    }
                } else {
                    $vcard[$sub->name] = $sub->data;
                }
            }
            $vcard['from'] = $xml->attrs['from'];
            $cb($vcard);
        });
        $id = htmlspecialchars($id);
        if ($jid != null) {
            $jid = htmlspecialchars($jid);
            $this->send('<iq type="get" id="' . $id . '" to="' . $jid . '"><vCard xmlns="vcard-temp" /></iq>');
        } else {
            $this->send('<iq type="get" id="' . $id . '"><vCard xmlns="vcard-temp" /></iq>');
        }
    }