Rails 3 Linkedin API 寶石 (Rails 3 Linkedin API gem)


問題描述

Rails 3 Linkedin API 寶石 (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.

‑‑‑‑‑

參考解法

方法 1:

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. 

(by hellionARun32)

參考文件

  1. Rails 3 Linkedin API gem (CC BY‑SA 3.0/4.0)

#linkedin #ruby-on-rails-3 #ruby-on-rails






相關問題

php中需要LinkedIn類型的朋友連接 (LinkedIn type friends connection required in php)

我可以在沒有明確用戶批准的情況下獲得 Linkedin oauth 訪問令牌嗎? (Could I get Linkedin oauth access token without explicitly user approve?)

Rails 3 Linkedin API 寶石 (Rails 3 Linkedin API gem)

如何在 iOS SDK 中獲取 LinkedIn 連接/朋友/聯繫人? (How to fetch LinkedIn connections/Friends/Contacts in iOS SDK?)

Linkedin 應用程序具有 OAuth 用戶令牌和 OAuth 用戶密鑰,它們會過期嗎? (Linkedin Application has OAuth User Token and OAuth User Secret, Do they Expire?)

LinkedIn 獲取個人資料提要或新聞提要 2015 (LinkedIn get profile feed or news feed 2015)

OAuth2::LinkedIn 錯誤 (OAuth2::Error with LinkedIn)

如果 Android 中未安裝 LinkedIn 本機應用程序,如何使用 LinkedIn 登錄和發布? (How to login and post with LinkedIn if LinkedIn native app is not installed in android?)

使用 JS API 集成 LinkedIn 登錄 (Integrate LinkedIn login using JS API)

Linkedin oauth2 r_liteprofile 沒有從 api 返回 (Linkedin oauth2 r_liteprofile not being returned from api)

LinkedIn OAuth2.0 使會話無效/強制重新授權 (LinkedIn OAuth2.0 Invalidate Session / Force re-authorization)

LinkedIn API v2 獲取用戶信息 (LinkedIn API v2 get user info)







留言討論