/**
* @TODO DESCR
* @param string $jid
* @param callable $cb
* @callback $cb ( )
*/
public function getVCard($jid = null, $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'];
call_user_func($cb, $vcard);
});
$id = htmlspecialchars($id);
$jid = htmlspecialchars($jid);
if ($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>');
}
}