简体   繁体   English

Python-LinkedIn API获取配置文件错误

[英]Python - LinkedIn API get profile error

This is for an internal project. 这是一个内部项目。 My end goal is to get details of my connections. 我的最终目标是获取我的连接的详细信息。 who are in same city as I am. 和我在同一个城市

I am new in using LinkedIn API . 我是使用LinkedIn API的新手。 I have used code mentioned in answer here to generate the access token. 我已使用此处答案中提到的代码来生成访问令牌。 Now I am using below line to get my LinkedIn profile. 现在,我使用下面的代码来获取我的LinkedIn个人资料。

application.get_profile(access_token['oauth_token'])

But I am getting below error. 但是我越来越错误了。

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    application.get_profile(access_token['oauth_token'])
  File "C:\Python34\lib\site-packages\python_linkedin-2.0-py3.4.egg\linkedin\linkedin.py", line 189, in get_profile
    response = self.make_request('GET', url, params=params, headers=headers)
  File "C:\Python34\lib\site-packages\python_linkedin-2.0-py3.4.egg\linkedin\linkedin.py", line 169, in make_request
    params.update({'oauth2_access_token': self.authentication.token.access_token})
AttributeError: 'str' object has no attribute 'token'

Can someone please help me? 有人可以帮帮我吗?

It is a bit late I guess. 我猜有点晚了。 But for future reference, this error comes from the fact that you need to call explicitly the token element from the linkedin application. 但是,为将来参考,此错误来自以下事实:您需要从linkedin应用程序中显式调用token元素。

For instance, to generate the application, you need to enter the following: 例如,要生成应用程序,您需要输入以下内容:

from linkedin_v2 import linkedin
application = linkedin.LinkedInApplication(token=access_token['oauth_token'])

From there, you can then call the different function from application (like "application.get_profile()"). 然后,您可以从那里调用与application不同的函数(例如“ application.get_profile()”)。

BR BR

I don't think you need to pass the auth token again to get your profile. 我认为您无需再次传递身份验证令牌即可获取个人资料。 I am also using the python lib. 我也在使用python lib。

application.get_profile()

Should return the basic information for your profile. 应该返回您个人资料的基本信息。 Then look into using selectors to specify what endpoints you want. 然后研究使用选择器指定所需的端点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM