我已经通过身份验证,正在从LinkedIn接收正确的数据,并收到此链接中所示的响应:
https://developer.linkedin.com/docs/ref/v2/profile/profile-picture
但是,我不确定如何从中提取图像:
"displayImage": "urn:li:digitalmediaAsset:C4D03AQGsitRwG8U8ZQ",
接下来我需要再次请求图片网址吗?
答案 0 :(得分:4)
对于其他正在寻找的人,我忽略了一个identifier
字段,它带有一个网址:
"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
}
要在ruby中获得上述响应,我需要执行以下操作:
url = 'https://api.linkedin.com/v2/me?projection=(id,firstName,lastName,profilePicture(displayImage~:playableStreams))'
res = RestClient.get(url, Authorization: "Bearer #{access_token}")
答案 1 :(得分:0)
使用此:
url = 'https://api.linkedin.com/v2/me?projection=(id,firstName,lastName,emailAddress,profilePicture(displayImage~:playableStreams))&oauth2_access_token=' + access_token