2017-10-19 110 views
1

現在我嘗試使用LinkedIn的Python API來獲取用戶的信息,下面是我的代碼:「NoneType」對象已通過蟒蛇linkedinapi沒有屬性錯誤

from linkedin import linkedin 

API_Key='...' 
API_Secret='...' 
Return_url='http://localhost:8000' 

authentication = linkedin.LinkedInAuthentication(API_Key, API_Secret, Return_url, linkedin.PERMISSIONS.enums.values()) 
print(authentication.authorization_url) # open this url on your browser 
application = linkedin.LinkedInApplication(authentication) 
application.get_profile() 

但是,它顯示錯誤:

AttributeError: 'NoneType' object has no attribute 'access_token'

而另一個問題是,如果我有一個人的名字,如何使用API​​來獲取該人的信息?

回答

0

不具備代表發表評論,但看到這樣的回答:Python: Attribute Error - 'NoneType' object has no attribute 'something'

這是Java空指針異常的等價物。無論您嘗試訪問「access_token」字段的對象是否爲空。如果該對象是函數調用返回的內容,那麼該函數調用可能失敗。

另見Authenticate to linkedin

problems with LinkedIn API connection

Using oauth2_access_token to get connections in linkedIn

+0

我不知道什麼是我的程序 – sweetyBaby

+0

你看我貼的鏈接的問題? – pellucidcoder

相關問題