function ParseContactsData() { $parts = explode('"id"', $this->RawSource); foreach ($parts as $v) { if (preg_match('/"displayName":"((?:[^"]*(?:(?<=\\\\)")?)*?)".*?"emails":\\[{"value":"([^"]*)/si', $v, $matches)) { $name = SPUtils::decode_html_escaped($matches[1]); $email = SPUtils::decode_html_escaped($matches[2]); if ($name == "") { $name = current(explode("@", $email)); } $this->__add_contact_item($name, $email); } else { if (preg_match('/emails":\\[{"value":"([^"]*).*?name":{"formatted":"((?:[^"]*(?:(?<=\\\\)")?)*?)"/si', $v, $matches)) { // else generally not needed any more $name = SPUtils::decode_html_escaped($matches[2]); $email = SPUtils::decode_html_escaped($matches[1]); if ($name == "") { $name = current(explode("@", $email)); } $this->__add_contact_item($name, $email); } } } if ($this->client->auth_url_revoke) { $this->client->get($this->client->auth_url_revoke); $this->client->__oauth_access_token = null; $this->client->oauth_token = null; $this->client->oauth_token_secret = null; } if ($this->ContactsCount) { return true; } $this->Error = ContactsResponses::ERROR_NO_CONTACTS; return false; }
protected function ParseContactsData() { $parts = explode('"id"', $this->RawSource); foreach ($parts as $v) { if (preg_match('/emails":\\[{"value":"([^"]*).*?name":{"formatted":"((?:[^"]*(?:(?<=\\\\)")?)*?)"/si', $v, $matches)) { $name = SPUtils::decode_html_escaped($matches[2]); $email = $matches[1]; if ($name == "") { $name = current(explode("@", $email)); } $this->__add_contact_item($name, $email); } } if ($this->ContactsCount) { return true; } $this->Error = ContactsResponses::ERROR_NO_CONTACTS; return false; }
function ParseContactsData() { preg_match_all('#<contact[^>]*>(.*?)</contact>#si', $this->RawSource, $contacts); foreach ($contacts[0] as $c) { if (preg_match_all('#<fields[^>]*>.*?<type>(.*?)</type>.*?<value>(.*?)</value>.*?</fields>#si', $c, $fields)) { $name = $email = ""; for ($i = 0; $i < count($fields[1]); $i++) { switch ($fields[1][$i]) { case "name": preg_match_all("#<[^>]*>(.*?)</[^>]*>#si", $fields[2][$i], $name_parts); $name = join(" ", $name_parts[1]); break; case "email": case "otherid": $email = $email ? $email : (strpos($fields[2][$i], "@") ? $fields[2][$i] : ""); break; case "yahooid": case "nickname": $name = $name ? $name : $fields[2][$i]; break; } } $name = SPUtils::decode_html_escaped($name); if ($name == "") { $name = current(explode("@", $email)); } $this->__add_contact_item($name, $email); } } if ($this->client->auth_url_revoke) { $this->client->get($this->client->auth_url_revoke); $this->client->__oauth_access_token = null; $this->client->oauth_token = null; $this->client->oauth_token_secret = null; } if ($this->ContactsCount) { return true; } $this->Error = ContactsResponses::ERROR_NO_CONTACTS; return false; }