Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving the profile image from LinkedIn API response

I've gone through the authentication and am receiving the correct data from LinkedIn and receiving a response as shown in this link:

https://developer.linkedin.com/docs/ref/v2/profile/profile-picture

However, I'm unsure how to extract the image from this:

"displayImage": "urn:li:digitalmediaAsset:C4D03AQGsitRwG8U8ZQ",

Do I need to make another request for the image url next?

like image 843
Matt Avatar asked Feb 01 '19 17:02

Matt


People also ask

What data can you extract from LinkedIn API?

Using the API for LinkedIn, you can get detailed information about LinkedIn groups based on the ID of the target groups. Below are some of the data you can get: ID, name, date of creation, logo, description, location, industries, etc. Learn more in the LinkedIn API documentation.


1 Answers

For anyone else looking, I overlooked there is an identifier field like so with a url:

"identifiers": [
 {
  "identifier": "https://media.licdn.com/dms/image/C4D03AQGsitRwG8U8ZQ/profile-displayphoto-shrink_100_100/0?e=1526940000&v=alpha&t=12345",
  "file": "urn:li:digitalmediaFile:     (urn:li:digitalmediaAsset:C4D03AQGsitRwG8U8ZQ,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_100_100,0)",
    "index": 0,
    "mediaType": "image/jpeg",
    "identifierExpiresInSeconds": 1526940000
}

To get the above response in ruby I'm doing the following:

url = 'https://api.linkedin.com/v2/me?projection=(id,firstName,lastName,profilePicture(displayImage~:playableStreams))'
res = RestClient.get(url, Authorization: "Bearer #{access_token}")
like image 139
Matt Avatar answered Sep 28 '22 08:09

Matt