hellion
hellion

Reputation: 4840

Rails 3 Linkedin API gem

I'm trying to set up the linkedin api in a rails 3 app using the linkedin gem. I don't want the user to have to authenticate my app in order for the API to get their info. I only need one piece of their public profile (the headline). So, maybe I should just be using xml or json to pull this off (not exactly sure how to get that with linkedin either).

I have the following in a helper so that I can call linkedin_header() in a loop of users. I only have 'client' as the last line of the following code while debugging. It outputs as expected (#). It seems like I am only a step away from success. How can I access a given users headline? I have tried using "client = client.profile(:url => 'linkedin_user_url')", but that return "Call must be made on behalf of a member".

 def linkedin_header(account_user) 
      user = User.find(account_user)
      account = Account.where(:user_id => user, :external_id => 1)
      api_key = 'aaaaaaaa'
      api_secret = 'bbbbbbbb'

      client = LinkedIn::Client.new(api_key, api_secret)
      rtoken = client.request_token.token # this returns correctly
      rsecret = client.request_token.secret # this returns correctly
      client
    # client = client.profile(:url => 'linkedin_user_url')
 end

So, I guess I have two questions. Is my request (public headline of any user) too simple for the above...should I be using XML or JSON. And, if Im close...can I make the API work for me without the user having to authenticate via linkedin.

Upvotes: 0

Views: 1654

Answers (1)

ARun32
ARun32

Reputation: 355

Based off of what I read from the LinkedIn API reference (http://developer.linkedin.com/documents/authentication)

You have to make requests to their API only after being authenticated. (Using OAuth Keys) Rather than just grabbing the publicly available information.

It seems like since you want a small piece of information (the public headline of any user) you'd want some sort of implementation like Facebook's OpenGraph. After looking around on LinkedIn, I don't see any sort of public implementation like that.

I would suggest checking out this gem:

https://github.com/yatishmehta27/linkedin-scraper

It seems to be the type of solution you're looking for.

Upvotes: 4

Related Questions