简体   繁体   English

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. 我正在尝试使用linkedin gem在rails 3应用程序中设置linkedin api。 I don't want the user to have to authenticate my app in order for the API to get their info. 我不希望用户必须对我的应用程序进行身份验证才能使API获得其信息。 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). 因此,也许我应该只使用xml或json来实现此目的(也不完全确定如何通过linkedin获得该信息)。

I have the following in a helper so that I can call linkedin_header() in a loop of users. 我在帮助器中具有以下内容,以便可以在用户循环中调用linkedin_header()。 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". 我尝试使用“ client = client.profile(:url =>'linkedin_user_url')”,但是返回“呼叫必须代表成员进行”。

 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. 我的要求(任何用户的公共标题)是否太简单了……我应该使用XML还是JSON。 And, if Im close...can I make the API work for me without the user having to authenticate via linkedin. 而且,如果即时通讯关闭了,我可以让我使用该API,而无需用户通过linkedin进行身份验证。

Based off of what I read from the LinkedIn API reference (http://developer.linkedin.com/documents/authentication) 基于我从LinkedIn API参考(http://developer.linkedin.com/documents/authentication)中阅读的内容

You have to make requests to their API only after being authenticated. 您仅需在通过身份验证后向其API发出请求。 (Using OAuth Keys) Rather than just grabbing the publicly available information. (使用OAuth密钥)而不是仅仅获取公开可用的信息。

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. 似乎由于您只需要一小部分信息(任何用户的公共标题),所以您需要某种实现,例如Facebook的OpenGraph。 After looking around on LinkedIn, I don't see any sort of public implementation like that. 在LinkedIn上浏览后,我看不到任何类似的公共实施方式。

I would suggest checking out this gem: 我建议您检查一下这个宝石:

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

It seems to be the type of solution you're looking for. 这似乎是您要寻找的解决方案类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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