问题
When i use the LinkedIn API to get profile information, the picture urls are sometime not accessible.
I get this response
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>403 - Forbidden</title>
</head>
<body>
<h1>403 - Forbidden</h1>
</body>
</html>
Upon further digging I find that LinkedIn returns something like this for original picture url
.../profile-originalphoto-shrink_900_1200...
However, when I go to LinkedIn.com and checkout the URL of the picture of the profile it looks something like this
.../profile-originalphoto-shrink_800_800...
Does anyone else face this issue? What is going on here?
I also verified that I'm using the correct scope "r_basicprofile"
回答1:
Rather than requesting the original picture-url, you can make a request to a resized picture-url. For example,
picture-url;size=400
where size can be 100, 200, or 400.
回答2:
I looked at the URL of my picture of my In Public profile and the one returned from the API.
The picture URL in the XML returned after the "?" for params v and t had "& ;" instead of "&":
e.g. https://media.licdn.com/.../profile-displayphoto-shrink_200_200/0?e=152800"&";v=beta"&";t=LJTrw_oj9npH06X1u0HjQ
replacing it with sth like pictureURL = pictureURL.replaceAll("& ;","&"); fixed the issue for me. Hope this helps
note that the there is an extra space between & and ; it would have formatted otherwise.
来源:https://stackoverflow.com/questions/50341586/linkedin-api-picture-urlsoriginal-forbidden-403-error