How to fetch Linkedin user data?

2019-01-28 16:35发布

I am using Linkedin API to fetch user content in RoR project. I am following this blog. Here is controller code:

Basic profile (which works fine)

client = get_client
profile = client.profile(:fields => ["first-name", "last-name", "maiden-name", "formatted-name" ,:headline, :location, :industry, :summary, :specialties, "picture-url", "public-profile-url"])

Experience and Positions:

client = get_client
positions = client.profile(:fields => [:positions]).positions.all

For Educations:

client = get_client
educations = client.profile(:fields => [:educations]).educations.all

Whereas get_client

def get_client
linkedin_oauth_setting = LinkedinOauthSetting.find_by_user_id(current_user.id)
client = LinkedIn::Client.new('aaadad', 'dadada', @@config)
client.authorize_from_access(linkedin_oauth_setting.atoken, linkedin_oauth_setting.asecret)
client
end

For scope I set :

:request_token_path => '/uas/oauth/requestToken?scope=r_fullprofile'

I am able to get Basic profile information but not others. For other fields I am getting empty []. What am I doing wrong here?

1条回答
The star\"
2楼-- · 2019-01-28 16:51

I think you need to ask Linkedin a special authorization to access this data. r_fullprofile is only for registered APIs.

  • Data that doesn't need any special authorization: r_basicprofile
  • Data that needs to apply for LinkedIn partnership program: r_fullprofile (See here)

Have a look at this documentation in Linkedin's website

To apply to Linkedin's program, visit this page

I applied this morning and they said they would come back to me within 15 days.

Good luck!

查看更多
登录 后发表回答