From 470b781f288fbb24c8b105cfdada215d83d84d4b Mon Sep 17 00:00:00 2001 From: Igor Khripchenko Date: Mon, 17 Jul 2023 10:56:49 +0200 Subject: [PATCH] Update Linkedin.php (#264) --- src/Providers/Linkedin.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Providers/Linkedin.php b/src/Providers/Linkedin.php index 1d8e0fc..f2e13f7 100644 --- a/src/Providers/Linkedin.php +++ b/src/Providers/Linkedin.php @@ -51,7 +51,7 @@ protected function getBasicProfile(string $token): array $response = $this->getHttpClient()->get($url, [ 'headers' => [ - 'Authorization' => 'Bearer '.$token, + 'Authorization' => 'Bearer ' . $token, 'X-RestLi-Protocol-Version' => '2.0.0', ], ]); @@ -65,7 +65,7 @@ protected function getEmailAddress(string $token): array $response = $this->getHttpClient()->get($url, [ 'headers' => [ - 'Authorization' => 'Bearer '.$token, + 'Authorization' => 'Bearer ' . $token, 'X-RestLi-Protocol-Version' => '2.0.0', ], ]); @@ -75,12 +75,13 @@ protected function getEmailAddress(string $token): array protected function mapUserToObject(array $user): Contracts\UserInterface { - $preferredLocale = ($user['firstName.preferredLocale.language'] ?? null).'_'.($user['firstName.preferredLocale.country'] ?? null); - $firstName = $user['firstName.localized.'.$preferredLocale] ?? null; - $lastName = $user['lastName.localized.'.$preferredLocale] ?? null; - $name = $firstName.' '.$lastName; + $preferredLocale = ($user['firstName']['preferredLocale']['language'] ?? null) . '_' . + ($user['firstName']['preferredLocale']['country'] ?? null); + $firstName = $user['firstName']['localized'][$preferredLocale] ?? null; + $lastName = $user['lastName']['localized'][$preferredLocale] ?? null; + $name = $firstName . ' ' . $lastName; - $images = $user['profilePicture.displayImage~.elements'] ?? []; + $images = $user['profilePicture']['displayImage~']['elements'] ?? []; $avatars = \array_filter($images, static fn ($image) => ($image['data']['com.linkedin.digitalmedia.mediaartifact.StillImage']['storageSize']['width'] ?? 0) === 100); $avatar = \array_shift($avatars); $originalAvatars = \array_filter($images, static fn ($image) => ($image['data']['com.linkedin.digitalmedia.mediaartifact.StillImage']['storageSize']['width'] ?? 0) === 800); @@ -91,8 +92,8 @@ protected function mapUserToObject(array $user): Contracts\UserInterface Contracts\ABNF_NICKNAME => $name, Contracts\ABNF_NAME => $name, Contracts\ABNF_EMAIL => $user['emailAddress'] ?? null, - Contracts\ABNF_AVATAR => $avatar['identifiers.0.identifier'] ?? null, - 'avatar_original' => $originalAvatar['identifiers.0.identifier'] ?? null, + Contracts\ABNF_AVATAR => $avatar['identifiers']['0']['identifier'] ?? null, + 'avatar_original' => $originalAvatar['identifiers']['0']['identifier'] ?? null, ]); } }