/** * load the user profile from the IDp api client */ function getUserProfile() { parent::getUserProfile(); try { // https://developer.linkedin.com/docs/signin-with-linkedin $response = $this->api->profile('~:(id,positions,location,industry)'); } catch (\LinkedInException $e) { throw new \Exception("User profile request failed! {$this->providerId} returned an error: {$e}", 6); } 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.", 6); } if ($data->{'positions'}) { $positions = $data->{'positions'}; $attributes = $data->{'positions'}->attributes(); if (isset($attributes['total']) && (int) $attributes['total'] > 0) { foreach ($positions->{'position'} as $position) { if ((string) $position->{'is-current'} == 'true') { $this->user->profile->position = (string) $position->title; if ($position->company) { $this->user->profile->company = (string) $position->company->name; } $this->user->profile->position = (string) $position->title; } } } } if ($data->{'industry'}) { $this->user->profile->industry = (string) $data->{'industry'}; } if ($data->{'location'}) { $location = $data->{'location'}; $this->user->profile->city = (string) $location->name; } return $this->user->profile; } else { throw new \Exception("User profile request failed! {$this->providerId} returned an invalid response.", 6); } }
function __construct($providerId, $config, $params = NULL) { parent::__construct($providerId, $config, $params); // TODO: Change the autogenerated stub $this->user = new PxHybridAuth_Hybrid_User(); }