简体   繁体   English

如何使用linkedin gem和omniauth获得更精细的LinkedIn用户信息?

[英]How do I get more granular LinkedIn user information using linkedin gem and omniauth?

I want to get a user's position information from their LinkedIn profile (company name, title, etc), but I can't get anything more than basic profile information (id, name, email, headline, and image). 我想从他们的LinkedIn个人资料(公司名称,职位等)中获取用户的位置信息,但我得到的不仅仅是基本的个人资料信息(身份证,姓名,电子邮件,标题和图片)。 I'm guessins this is just a syntax thing since I'm requesting access to all fields upon user's authentication. 我猜这只是一种语法,因为我在用户身份验证时请求访问所有字段。

from user.rb 来自user.rb

    def self.from_omniauth(auth)
      where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
        user.provider = auth.provider
        user.uid = auth.uid
        user.name = auth.info.name
        user.email = auth.info.email
        user.headline = auth.info.headline
        **user.company = auth.info.company**
        user.avatar = auth.info.image
        user.password = SecureRandom.urlsafe_base64(n=6)
        user.save!    
    end  

from devise.rb 来自devise.rb

  config.omniauth :linkedin, "abcdefghijk", "abcdefghijk", 
  # :scope => 'r_basicprofile r_emailaddress rw_nus r_fullprofile r_contactinfo r_network rw_company_admin',
  # :fields =>
  :scope => 'r_basicprofile r_emailaddress rw_nus r_fullprofile r_contactinfo r_network rw_company_admin', 
  :fields => ["id", "email-address", "first-name", "last-name", 
                  "headline", "industry", "picture-url", "public-profile-url", 
                  "location", "connections", "skills", "date-of-birth", "phone-numbers",        
                  "educations", "three-current-positions" ]

Do I need to add fields to devise.rb or am I being an idiot and formatting user.company = auth.info.company wrong? 我是否需要向devise.rb添加字段,或者我是一个白痴并格式化user.company = auth.info.company错误?

Thanks! 谢谢!

[edit] okay, found it. [编辑]好吧,找到了。 The devise.rb field definition is wrong. devise.rb字段定义错误。 (Probably outdated, I used the same and it was copied from somewhere.) (可能已经过时了,我使用了同样的东西,它是从某处复制的。)

Correct name now is just "positions", not "three-current-positions" 正确的名字现在只是“位置”,而不是“三个当前位置”

After that, auth.extra.info.positions becomes available (with these params: https://developer.linkedin.com/docs/fields/positions ) 之后, auth.extra.info.positions变得可用(使用这些参数: https//developer.linkedin.com/docs/fields/positions

访问用户信息ID的格式为:

user.name = auth["info"]["name"]

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

相关问题 如何使用'linkedin'gem获得用户推荐? - How to get recommendation for the user using 'linkedin' gem? 如何使用gem'linkedin',:git =>“ git://github.com/pengwynn/linkedin.git”登录用户的完整个人资料信息? - How to get logged in user's complete profile information using gem 'linkedin', :git => “git://github.com/pengwynn/linkedin.git”? omn​​iauth和linkedin gem的cookie持久性 - cookie persistence with omniauth and linkedin gem 在linkedin插件中使用omniauth的linkedin令牌 - using omniauth's linkedin token in linkedin plugin 如何使用linkedin gem在rails中解析配置文件? - How do I used the linkedin gem to parse a profile in rails? 新的LinkedIn权限问题(Rails omniauth-linkedin gem) - New LinkedIn Permissions Problems (Rails omniauth-linkedin gem) 与omniauth linkedin Ruby宝石的大型配置文件图像 - Large profile image with omniauth linkedin Ruby gem 将pengwynnlinkedin gem与devise / omniauth结合? - Combining pengwynn linkedin gem with devise/omniauth? 当用户已经登录时,如何使用Twitter gem和Omniauth gem获取用户的访问令牌? - How do I fetch the access token for a user using the Twitter gem and the Omniauth gem when the users is already logged in? 如何结合 Omniauth 和 OAuth 登录到linkedin并检索 API 数据? - How do I combine Omniauth and OAuth to sign into linkedin and retrieve API data?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM