Jizbo Jonez
Jizbo Jonez

Reputation: 1290

Get large profile picture from linked in API using php

I am using the following to get information from linkedin API :

$user = fetch('GET', '/v1/people/~:(firstName,lastName,pictureUrl,headline,emailAddress,publicProfileUrl)');

For the pictureUrl I am getting a small image (80px x 80px) even though a larger one was uploaded. How can I get the larger images?

I have looked around StackExchange and see mention of picture-urls::(original) but can't seem to get that to work, perhaps I am using it wrong. This is what i tried :

$user = fetch('GET', '/v1/people/~:(firstName,lastName,pictureUrls::(original),headline,emailAddress,publicProfileUrl)');

On the API page here https://developer.linkedin.com/documents/profile-fields#profile it says to use "first-name" for example, but that doesn't give me any results except for returning "0". So this doesn't work :

$user = fetch('GET', '/v1/people/~:(first-name)');
echo $user->first-name;

and this doesn't work :

$user = fetch('GET', '/v1/people/~:(firstname)');
echo $user->firstname;

but this does :

$user = fetch('GET', '/v1/people/~:(firstName)');
echo $user->firstName;

Where is this formatting even coming from, I can't see it listed in linkedin API pages, I found it on some obscure website after an extensive google search.

Upvotes: 2

Views: 5141

Answers (1)

Jizbo Jonez
Jizbo Jonez

Reputation: 1290

After checking over the script I 'borrowed', I saw that it was asking to use JSON syntax in the header:

'header' => "Authorization: Bearer " . $_SESSION['access_token'] . "\r\n" . "x-li-format: json\r\n"

I removed the x-li-format: json\r\n part and now I am able to use picture-urls::(original) successfully as @Darren suggested.

So all well and good. Still though, LinkedIn should have a listing of the alternative JSON syntax in the API docs, and they should also allow the use of colon selectors in JSON somehow.

Upvotes: 2

Related Questions