Linkedin API - Picture-urls::original - forbidden 403 error

為{幸葍}努か 提交于 2019-12-11 08:03:03

问题


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 "&amp ;" instead of "&":

e.g. https://media.licdn.com/.../profile-displayphoto-shrink_200_200/0?e=152800"&amp";v=beta"&amp";t=LJTrw_oj9npH06X1u0HjQ

replacing it with sth like pictureURL = pictureURL.replaceAll("&amp ;","&"); fixed the issue for me. Hope this helps

note that the there is an extra space between &amp and ; it would have formatted otherwise.



来源:https://stackoverflow.com/questions/50341586/linkedin-api-picture-urlsoriginal-forbidden-403-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!