【问题标题】:Accessing user's current company with django social-auth使用 django social-auth 访问用户当前的公司
【发布时间】:2015-04-09 22:27:44
【问题描述】:

我已在我的网站上成功设置了 Linkedin 社交身份验证 django-socialauth。我能够检索顶级配置文件字段,例如标题,没问题,在我的settings.py中设置如下:

LINKEDIN_EXTRA_FIELD_SELECTORS = [
'email-address',
'headline',
'industry',
'location',
'picture-url',
'specialties',
'positions',
'relation-to-viewer',
'skills',
'public-profile-url',    
]
LINKEDIN_EXTRA_DATA = [('id', 'id'),
                   ('first-name', 'first_name'),
                   ('last-name', 'last_name'),] + [
                       (field, field.replace('-', '_'), True)
                       for field in LINKEDIN_EXTRA_FIELD_SELECTORS
                   ] 

不幸的是,我不知道如何从这种界面使用 Linkedin 字段选择器语法访问“较低级别”。

例如,从这里开始:https://developer.linkedin.com/forum/how-get-api-current-company-position-using-parameter-current,可以使用以下语法访问用户的当前公司:

positions:(is-current,company:(name))

如何在上面的 settings.py 变量中包含这个选择器?像上面那样天真地插入选择器会导致 KeyErrors 或 Null 值。

【问题讨论】:

    标签: django linkedin django-socialauth python-social-auth


    【解决方案1】:

    想通了。从链接中检索字典“详细信息”后,您可以检索当前公司:

     current_companies = [position['company']['name'] for position in details['positions']['position'] if position['is-current']=='true']
    

    【讨论】:

      猜你喜欢
      • 2021-07-31
      • 2014-02-13
      • 2012-12-07
      • 1970-01-01
      • 1970-01-01
      • 2017-05-23
      • 2012-10-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多