2

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.

Jizbo Jonez
  • 1,230
  • 10
  • 25
  • 41
  • Is it possible that only the 80x80 image is available via the API? What do the docs say? – halfer Jan 21 '15 at 01:56
  • I've already mentioned that a larger one was uploaded. I can't see much in docs about it but like I said I've searched this site and apparently it can be done. – Jizbo Jonez Jan 21 '15 at 01:59
  • 2
    Why are people down-voting this? It's on topic and is a legit question...? – Darren Jan 21 '15 at 02:00
  • 2
    Btw, @JizboJonez a look on their forums (albeit the threads are old), seems to warrant that you should try to use `picture-urls::(original)` - [`Source`](http://stackoverflow.com/a/9513804/2518525) – Darren Jan 21 '15 at 02:02
  • lol yeah it seems that way...and yes I saw that in the forums but the thing is on this page https://developer.linkedin.com/documents/profile-fields it gives a list of variables that can be used, for example "first-name" but for some reason things don't work for me in that format. As you can see i had to use "firstName" to get it to work... so what is the formatting for "picture-urls::(original)" because as it is it doesn't work for me. I tried "pictureUrls::(original)" – Jizbo Jonez Jan 21 '15 at 02:14
  • Are you using the latest version of their API ? – Darren Jan 21 '15 at 02:29
  • I seem to be, there is "v1" in my GET url and all examples I see are using this same address, even the ones telling me to use "first-name" (hyphen formatting)... yet hyphens don't work for me... strange – Jizbo Jonez Jan 21 '15 at 02:36
  • I just read on this page https://developer.linkedin.com/blog/tips-and-tricks-field-selectors that I am using JSON formatting... which brings me back to what is the JSON format for "picture-urls::(original)"... and where are these formats even listed? ...and I just noticed on that page someone stating "won't allow there to be any colon characters in the URL" in the comments section... so I'm not the only one facing this problem. Maybe I should just not use JSON – Jizbo Jonez Jan 21 '15 at 02:41
  • It seems that NOT using JSON isn't that easy either, they say if you want to use JSON you should have this on the end of your urls "?format=json" like so http://api.linkedin.com/v1/people/~:(firstName,lastName)?format=json" ...I am not even doing that so I don't know why it won't allow me to just use standard syntax so I can take advantage of selectors and then be able to get the large picture urls... wak as, it seems I'm being forced to use JSON whether I like it or not – Jizbo Jonez Jan 21 '15 at 02:52

1 Answers1

2

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
Jizbo Jonez
  • 1,230
  • 10
  • 25
  • 41