apiRequest('me'); $data = new Data\Collection($response); if (!$data->exists('id')) { throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); } $userProfile = new User\Profile(); $userProfile->identifier = $data->get('id'); $userProfile->displayName = $data->get('name'); $userProfile->firstName = $data->get('first_name'); $userProfile->lastName = $data->get('last_name'); $userProfile->gender = $data->get('gender'); $userProfile->profileURL = $data->get('link'); $userProfile->email = $data->filter('emails')->get('preferred'); $userProfile->emailVerified = $data->filter('emails')->get('account'); $userProfile->birthDay = $data->get('birth_day'); $userProfile->birthMonth = $data->get('birth_month'); $userProfile->birthYear = $data->get('birth_year'); $userProfile->language = $data->get('locale'); return $userProfile; } /** * {@inheritdoc} */ public function getUserContacts() { $response = $this->apiRequest('me/contacts'); $data = new Data\Collection($response); if (!$data->exists('data')) { throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); } $contacts = []; foreach ($data->filter('data')->toArray() as $idx => $entry) { $userContact = new User\Contact(); $userContact->identifier = $entry->get('id'); $userContact->displayName = $entry->get('name'); $userContact->email = $entry->filter('emails')->get('preferred'); $contacts[] = $userContact; } return $contacts; } }