[英]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.