function getUserProfile()
{
try {
// http://developer.linkedin.com/docs/DOC-1061
$response = $this->api->profile('~:(' . implode(',', $this->config['fields']) . ')');
} catch (LinkedInException $e) {
throw new Exception("User profile request failed! {$this->providerId} returned an error: {$e->getMessage()}", 6, $e);
}
if (isset($response['success']) && $response['success'] === true) {
$data = @new SimpleXMLElement($response['linkedin']);
if (!is_object($data)) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid xml data: " . Hybrid_Logger::dumpData($data), 6);
}
$this->user->profile->identifier = (string) $data->{'id'};
$this->user->profile->firstName = (string) $data->{'first-name'};
$this->user->profile->lastName = (string) $data->{'last-name'};
$this->user->profile->displayName = trim($this->user->profile->firstName . " " . $this->user->profile->lastName);
$this->user->profile->email = (string) $data->{'email-address'};
$this->user->profile->emailVerified = (string) $data->{'email-address'};
if ($data->{'positions'}) {
$this->user->profile->job_title = (string) $data->{'positions'}->{'position'}->{'title'};
$this->user->profile->organization_name = (string) $data->{'positions'}->{'position'}->{'company'}->{'name'};
}
if (isset($data->{'picture-url'})) {
$this->user->profile->photoURL = (string) $data->{'picture-url'};
} elseif (isset($data->{'picture-urls'})) {
// picture-urls::(original)
$this->user->profile->photoURL = (string) $data->{'picture-urls'}->{'picture-url'};
} else {
$this->user->profile->photoURL = "";
}
$this->user->profile->profileURL = (string) $data->{'public-profile-url'};
$this->user->profile->description = (string) $data->{'summary'};
if ($data->{'phone-numbers'} && $data->{'phone-numbers'}->{'phone-number'}) {
$this->user->profile->phone = (string) $data->{'phone-numbers'}->{'phone-number'}->{'phone-number'};
} else {
$this->user->profile->phone = null;
}
if ($data->{'date-of-birth'}) {
$this->user->profile->birthDay = (string) $data->{'date-of-birth'}->day;
$this->user->profile->birthMonth = (string) $data->{'date-of-birth'}->month;
$this->user->profile->birthYear = (string) $data->{'date-of-birth'}->year;
}
return $this->user->profile;
} else {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response: " . Hybrid_Logger::dumpData($response), 6);
}
}