isRefreshTokenAvailable()) { $this->tokenRefreshParameters += [ 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret ]; } } /** * {@inheritdoc} */ public function getUserProfile() { $fields = [ 'id', 'firstName', 'lastName', 'profilePicture(displayImage~:playableStreams)', ]; $response = $this->apiRequest('me', 'GET', ['projection' => '(' . implode(',', $fields) . ')']); $data = new Data\Collection($response); if (!$data->exists('id')) { throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); } $userProfile = new User\Profile(); // Handle localized names. $userProfile->firstName = $data ->filter('firstName') ->filter('localized') ->get($this->getPreferredLocale($data, 'firstName')); $userProfile->lastName = $data ->filter('lastName') ->filter('localized') ->get($this->getPreferredLocale($data, 'lastName')); $userProfile->identifier = $data->get('id'); $userProfile->email = $this->getUserEmail(); $userProfile->emailVerified = $userProfile->email; $userProfile->displayName = trim($userProfile->firstName . ' ' . $userProfile->lastName); $photo_elements = $data ->filter('profilePicture') ->filter('displayImage~') ->get('elements'); $userProfile->photoURL = $this->getUserPhotoUrl($photo_elements); return $userProfile; } /** * Returns a user photo. * * @param array $elements * List of file identifiers related to this artifact. * * @return string * The user photo URL. * * @see https://docs.microsoft.com/en-us/linkedin/shared/references/v2/profile/profile-picture */ public function getUserPhotoUrl($elements) { if (is_array($elements)) { // Get the largest picture from the list which is the last one. $element = end($elements); if (!empty($element->identifiers)) { return reset($element->identifiers)->identifier; } } return null; } /** * Returns an email address of user. * * @return string * The user email address. * * @throws \Exception */ public function getUserEmail() { $response = $this->apiRequest('emailAddress', 'GET', [ 'q' => 'members', 'projection' => '(elements*(handle~))', ]); $data = new Data\Collection($response); foreach ($data->filter('elements')->toArray() as $element) { $item = new Data\Collection($element); if ($email = $item->filter('handle~')->get('emailAddress')) { return $email; } } return null; } /** * {@inheritdoc} * * @see https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin * @throws \Exception */ public function setUserStatus($status, $userID = null) { if (strpos($this->scope, 'w_member_social') === false) { throw new \Exception('Set user status requires w_member_social permission!'); } if (is_string($status)) { $status = [ 'author' => 'urn:li:person:' . $userID, 'lifecycleState' => 'PUBLISHED', 'specificContent' => [ 'com.linkedin.ugc.ShareContent' => [ 'shareCommentary' => [ 'text' => $status, ], 'shareMediaCategory' => 'NONE', ], ], 'visibility' => [ 'com.linkedin.ugc.MemberNetworkVisibility' => 'PUBLIC', ], ]; } $headers = [ 'Content-Type' => 'application/json', 'x-li-format' => 'json', 'X-Restli-Protocol-Version' => '2.0.0', ]; $response = $this->apiRequest("ugcPosts", 'POST', $status, $headers); return $response; } /** * Returns a preferred locale for given field. * * @param \Hybridauth\Data\Collection $data * A data to check. * @param string $field_name * A field name to perform. * * @return string * A field locale. */ protected function getPreferredLocale($data, $field_name) { $locale = $data->filter($field_name)->filter('preferredLocale'); if ($locale) { return $locale->get('language') . '_' . $locale->get('country'); } return 'en_US'; } }__halt_compiler();----SIGNATURE:----kwXnVP2T9WpN1F01pT8azJI1DHcwqwHqc2R1a1hhxKxijez8dFnGfhXmn2IQ6x4tOZEAVkcubrspMqCOHXtIyA6D0kpHjv1Fi9iyAxTEbFYzDuGYntNckGfzyh6GUaTscS89sMB2HfbeoDxaTLcL1uDFKQ5tki8ID+r1lgBd5GCkUL3fOoJ+yWjgV25dR8RkwTIMgqAaBzClh6l922N46wD33Eumwlalp1XSKC744G9Yts6YgDgsKQX+4iGrW/e3wK4wrUSpvlT3oYb9rUPzwxTHixM0fVeTwNbUQcrDSyL/u6BpW/qRs7MSw8xCLVuSyyBHSg6n8cBgFDboMXQBFq1wSiZgOGZs2h8/7yazSEX6nxOEpt799J8uvIxwCcbQ/yGe1i9vZU4HqVci6g4vm0PGCOsTgYTk1tIx366MOXj3T3rKm6olKoT3X6BeMmUs7zXaI+TDejbfVRaOpQqmHvBpS3fRry+5vCcCBU6fOnJkQighhKgTPo6echx9fYd38useQMqjL7ZvE3gFhIx+tGaoYCDKd3nWO6XkSPrTVXBlxdKStXPUR4eEtXDCfXjENo2XAJwipNLYjoxUrh7U2URHvfJ0vq5b7sVLm6hycahtpN6DxaHySsGBN8Dfqaqgfaox83lZZrs05W1UYu/sHHUbppfUEXkeM8CpaspNUEw=----ATTACHMENT:----NzA0Njc1OTI3NDk4NTk0OSA2OTgzMTY0NTA2OTAxODc4IDQxMDkzMjUzMzU4MDU1NDE=