我的应用程序利用经过身份验证的请求来检索成员个人资料数据。尝试迁移到Linkedin Api版本2时,我找不到任何资源可向该应用添加当前权限。例如,我们目前可以检索成员的职位,但是Linkedin v2 Api不允许这样做。 Linkedin帮助中有关于此的常见问题解答。但是它说Linkedin合作伙伴计划尚未确定。
成员权限和应用程序权限之间也存在歧义。哪个权限属于哪个组?例如,“ r_1st_connections”属于哪个权限组?如何访问新的API,例如connections api?您可以在下面找到相关代码的一部分。
self._scope = "id,first-name,last-name,email-address,publications,skills,courses,headline,location,industry,current-share," \
"summary,three-past-positions,date-of-birth,specialties,positions,educations,num-connections,languages,num-connections-capped,picture-url"
#this is version 1 of linkedin api
url = "https://api.linkedin.com/v1/people/~:(" + self._scope + ")?format=json&oauth2_access_token=" + token
#this print information about requested scopes
print(requests.get(url))
#this is v2
data = None
params = {'oauth2_access_token': token}
url = 'https://api.linkedin.com/v2/me?projection=id,firstName,lastName'
headers = {'Content-Type': 'application/json','X-RestLi-Protocol-Version':'2.0.0'}
kw = dict(data=data, params=params,
headers=headers, timeout=60)
response = requests.request("GET", url, **kw)
status_code = response.status_code
content = json.loads(response.content)
return content