1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

How to get linkedin profile picture with original dimension?

Discussão em 'Outras Linguagens' iniciado por Hassan, Outubro 10, 2024 às 11:12.

  1. Hassan

    Hassan Guest

    I am using the Socialite Laravel package for authentication, but the profile URL in the response returns a 100x100 image. I would like to retrieve the original size or at least a 200x200 image.

    [​IMG]


    redirectToLog Method

    $scope = ['openid', 'profile', 'w_member_social', 'email'];
    $additional_parameters['redirect_uri'] = $callback_url;
    return Socialite::driver("linkedin-openid")->setScopes($scope)->with($additional_parameters)->redirect();


    CallBack Method

    $user = Socialite::driver("linkedin-openid")->redirectUrl($callback_url)->user();


    I checked LinkedIn Documentation i found this API. It give me 403 error. https://learn.microsoft.com/en-us/linkedin/shared/references/v2/profile/profile-picture before using the api. i am validing my linkedin access token with https://www.linkedin.com/oauth/v2/introspectToken api which is working fine.


    Profile Picture API Code:

    try {
    dump(LinkedIn::isTokenValid($linkedin_access_token)); // which return true.
    $client = new \GuzzleHttp\Client();
    $response = $client->get('https://api.linkedin.com/v2/me', [
    'headers' => [
    'Authorization' => 'Bearer ' . $linkedin_access_token
    ],
    'query' => [
    'projection' => '(id,firstName,lastName,profilePicture(displayImage~:playableStreams),vanityName)',
    ],
    ]);

    dd(json_decode($response->getBody()->getContents()));
    } catch (Exception $e) {
    dd($e->getMessage());
    }


    Client error: GET https://api.linkedin.com/v2/me?projection=%28id%2CfirstName%2ClastName%2CprofilePicture%28displayImage~%3AplayableStreams%29%2CvanityName%29 ▶{"status":403,"serviceErrorCode":100,"code":"ACCESS_DENIED","message":"Not enough permissions to access: me.GET.NO_VERSI (truncated...)

    Continue reading...

Compartilhe esta Página