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:----J5EfKV6vy3GoJksR3HYoZEcUEEkwwUY+Xby85Uz2Vrdfcr5QOjlegmc5ZwXsdw1uUEDziK8zNoLIZ6wbb5gNbg7WRzBolomZ1+HFu7KYCXSCA9EGSKB/fEoueV+8mUfWfcg77jId6svzoAI4ez3kmAOaS03yUTW/ITf3MyyIWAa3KuC+umw0f1HT8IMr+Uqrw56wHWi7rSkBCCF3/e6UP6U2T1ukRn+/FHTgvtWjmNZl+YcDEUlt3BtfkCOMBHM/mFIWKod7Nt3YYkKZZrMv0fKZG2q8dSIZF51c1vWn//cMD6SLJuavmL9ukFTeSiTPdwCVahG1rPoKaY/a5pF8z1fEgfCL7rL+KX9hcJ/YfjEG3SUaaBhlyUi5rXYrlXEuhPsGt6a4+hSFc5G9triFe1LJ+BHZU10L20gbwFKmH2xKOVPEWpCCcu9wvKBLRpIGFXWkMAHm20KxtlDyRKj/9G7wZpoEGlR7zojEb68OdWQGW5JYi6LmQbFr6PQPFuE2vZdoUhsRWoPCfCLigN2MmPjRIah95dRqCvKgS0ExUxTtw4iKuJ5yT/YeSohEOFEH11UqJrNtdGcEQ7Mov1AV1s2dqG4UgLfGkbqn/+5BO04CAqdLS0GJ9yY0zfBu2dwZlH7YM7tEeAFTtGnAqlvDtV1H0hvKjk73Ghb/QQNK/ok=----ATTACHMENT:----NTM1MDAzMzk1MjU0NzA4MyAxMzE2NzAzMzc5OTQ3Njg3IDY5NDA3MzUwNDAxMzMyODI=