简体   繁体   中英

Ruby Rails LInkedIn Gem (get connected or non-connected profile information)

After getting a profile hash from the LinkedIn Ruby Gem, but I'm looking for a way to get more information from the user, like skills, their connections, their email, their profile pic, etc. I'm not having any trouble accessing this info from the currently authenticated user, only getting this kind of information from the authenticated user's connections, and from public profiles.

In my Rails app I have a users/show.haml.html that does this:

def show
    #@users = User.all
    @profile = linkedin_client.profile(:id => params[:id])
    #how to get this user's connections etc?
  end

For the currently authenticated user it's relatively easy, to get the positions, id, and connections, just do this:

@positions = linkedin_client.profile(:fields => %w(positions)).positions.all 
  @id = linkedin_client.profile(:fields => 'id').id
  @connections = linkedin_client.connections.all

Anybody know how I can get similar information with connections, or even non-connected public profiles? Perhaps I should use another tool like linkedin-scraper?

Thanks!

The answer is to use :fields then specify which profile fields you'd like returned like this:

@profile = linkedin_client.profile(:id => params[:id], :fields => %w(id first-name last-name location picture_url public_profile_url headline industry))

hope this helps somebody.

我认为,如果您需要更多信息,可以随时使用linkedin-scraper gem https://github.com/yatishmehta27/linkedin-scraper

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM