Giter VIP home page Giter VIP logo

linkedin's Introduction

LinkedIn

Ruby wrapper for the LinkedIn API. The LinkedIn gem provides an easy-to-use wrapper for LinkedIn's REST APIs.

Travis CI : Build Status

Installation

gem install linkedin

Documentation

http://rdoc.info/gems/linkedin

Usage

View the Examples

Changelog

View the Changelog

TODO

  • Update and correct test suite
  • Change to Faraday for authentication
  • Implement Messaging APIs

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Make sure your test doesn't just check of instance of LinkedIn::Mash ๐Ÿ˜„.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright (c) 2013-Present Matt Kirk 2009-11 Wynn Netherland. See LICENSE for details.

linkedin's People

Contributors

abhinaykumar avatar alexdowad avatar avanrielly avatar bcantin avatar brentkastner avatar davidgriffiths avatar dkarp avatar hexgnu avatar hundredwatt avatar javan avatar joshk avatar jwreagor avatar leereilly avatar leonid-shevtsov avatar micahcraig avatar mijoharas avatar papricek avatar pbechu avatar pengwynn avatar renatosnrg avatar rmm5t avatar robertwbradford avatar ryanatwork avatar sabril avatar sahild avatar santib avatar schallereqo avatar sferik avatar sohair63 avatar tadast avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

linkedin's Issues

How can I get the pin?

It looks like from the desktop I get the authorization URL to get the pin.

It looks like I can use request_token.params[:oauth_token] ...these are the same?

Ruby 1.9 error on require: undefined method 'delegate'

ruby-1.9.2-p0 > require 'linkedin'
NoMethodError: undefined method delegate' for ROXML::XMLRef:Class from /Users/igrigorik/.rvm/gems/ruby-1.9.2-p0/gems/roxml-3.1.5/lib/roxml/xml/references.rb:10:inclass:XMLRef'
from /Users/igrigorik/.rvm/gems/ruby-1.9.2-p0/gems/roxml-3.1.5/lib/roxml/xml/references.rb:8:in <module:ROXML>' from /Users/igrigorik/.rvm/gems/ruby-1.9.2-p0/gems/roxml-3.1.5/lib/roxml/xml/references.rb:1:in<top (required)>'

New LinkedIn API Bug with /v1/person/~/shares (v0.2.2)

I've been using the #share method to post shares to people's profiles using the following code:

  client = LinkedIn::Client.new(...)
  client.authorize_from_access(...)
  client.share(:comment => "Hello World")

Starting sometime this weekend, LinkedIn's API began returning a 500 response to every attempt I made at this request. I posted this to their developer forum and they responded that its a bug on their end related to XML parsing: https://developer.linkedin.com/forum/getting-500-error-response-v1peopleshares

By trial and error, I figured out a way to get the above code working again. With just a comment, you can remove the content node in the XML. I monkey patched the #share_to_xml function to implement this work around:

LinkedIn::Client.class_eval {
  private
  def share_to_xml(options={})
    doc = Nokogiri.XML('<share><comment/><content><title/><submitted-url/><submitted-image-url/></content><visibility><code/></visibility></share>')
    doc.encoding = 'UTF-8'

    {:comment => 'comment', :title => 'title', :url => 'submitted-url', :image_url => 'submitted-image-url'}.each do |key, name|
    doc.at_css(name).content = options[key] if options[key]
    end

    doc.at_css('visibility > code').content = options[:visibility] || options[:visability] # backward-compatible typo fix

    ### MONKEY ###
    content_fields = [:title, :url, :image_url]
    unless options.values_at(content_fields).compact.any?
     doc.xpath('//content').remove
    end
    ### MONKEY ###

    doc.to_xml
  end
}

I asked on the forum if they are going to fix the issue. If they respond and say they aren't or don't respond, I can do a proper patch and submit a Pull Request

Profile fetching fails

After the OAuth authorization and verification is done and you have auth_token and auth_secret, making a profile request fails because URL is not setup correctly on client. Hence the request fails with the following trace:

oauth (0.4.5) lib/oauth/request_proxy/base.rb:94:in `normalized_uri'
oauth (0.4.5) lib/oauth/request_proxy/base.rb:114:in `signature_base_string'
oauth (0.4.5) lib/oauth/signature/base.rb:77:in `signature_base_string'
oauth (0.4.5) lib/oauth/signature/hmac/base.rb:12:in `digest'
oauth (0.4.5) lib/oauth/signature/base.rb:65:in `signature'
oauth (0.4.5) lib/oauth/signature.rb:23:in `sign'
oauth (0.4.5) lib/oauth/client/helper.rb:45:in `signature'
oauth (0.4.5) lib/oauth/client/helper.rb:75:in `header'
oauth (0.4.5) lib/oauth/client/net_http.rb:91:in `set_oauth_header'
oauth (0.4.5) lib/oauth/client/net_http.rb:30:in `oauth!'
oauth (0.4.5) lib/oauth/consumer.rb:227:in `sign!'
oauth (0.4.5) lib/oauth/consumer.rb:191:in `create_signed_request'
oauth (0.4.5) lib/oauth/consumer.rb:162:in `request'
oauth (0.4.5) lib/oauth/tokens/consumer_token.rb:25:in `request'
oauth (0.4.5) lib/oauth/tokens/access_token.rb:12:in `request'
oauth (0.4.5) lib/oauth/tokens/access_token.rb:27:in `get'
linkedin (0.3.1) lib/linked_in/helpers/request.rb:15:in `get'
linkedin (0.3.1) lib/linked_in/api/query_methods.rb:32:in `simple_query'
linkedin (0.3.1) lib/linked_in/api/query_methods.rb:8:in `profile'

A workaround is to make a "client.request_token" call before a profile call that will setup the api request target site properly. My current monkey patch is to add the make the path in lib/helpers/request_helpers.rb include "https://api.linkedin.com", but not sure if this is the right fix.

oauth 0.4.0 is out, gemspec update ?

Hi, I won't re-fork the project for a dependency update :)
The linkedin gem requires oauth 0.3.x, but 0.4.0 is out and no compatibility problem should happen.

how do I use relation-to-viewer:(related-connections) field?

Hello, for a given 2nd degree connection to a User, I want to use this field described in the API documents, but not sure what the () means in terms of accessing it using the linkedin gem?

How would I list the person objects that are the 1st-degree connections to those selected 2nd degrees?

Manual inclusion of :fields => []

This is somewhat a continuation of: http://github.com/pengwynn/linkedin/issues/closed#issue/3

Basically, without knowing you have to explicitly set which fields to include, you're completely out of luck. I burned time on it awhile before I stumbled the closed issue that solved it. ;) Not sure if you've updated the docs at all (I couldn't find it), but I'd heavily suggest doing that.

Along those lines- not sure if there's a way around this whole process, but it did seem pretty non-intuitive to me. It'd be nice to get at those fields without explicitly stating them.

And as a final, last related note: this feels really weird to have to do:

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

To pluralize, or not to pluralize; that is the question. Thanks though, now that I figured out the :fields trick; sorry for a vague, loosely-connected ticket!

education is empty?

I am not sure if i am using this right. I did some search with:
people=client.search(:options...) and it does return some people. But the education is an empty array if I do this: people.profiles[0].education. However, I can tell that person's linkedin profile (from the web) does have some education information. Am I miss something in here?

Thanks
James

undefined method `downcase' for nil:NilClass

Why am I getting this error? I get the atoken and asecret from the authentication hash after using OmniAuth. Seems okay, but then when I try to access the profile method, it borks:

  8     @user = User.find(params[:id]) 
  9     @client = LinkedIn::Client.new(ENV["LINKEDIN_KEY"], ENV["LINKEDIN_SECRET"]) 
 10     @client.authorize_from_access(@user.atoken, @user.asecret) 
 11     if @user == current_user 
 12       @client.profile 
 13     else 
 14       @client.profile(:id => @user.uid) 
 15     end 
 16   end 

Network Updates Mesh Issue

When trying to retrieve network updates for a given user, the returned Mash doesn't seem to allow you to access the update_content within an update object.

# controller
@network_updates = @linkedin_client.network_updates

# view
@network_updates.updates.each do |update|
  update.respond_to?(:update_content)
end

The following will always return false for every update object despite the fact that upon inspection, there is definitely an update-content Nokogiri XML node.

Incompatible with Omniauth 1.0

I could n't install the Linked gem and omniauth gem together because Omniauth 1.0 supports only hashie > 1.2 but linkedin only support hashie>1.1.0

Better syntax to get the public profile

Today the code to get the public profile of yourself:
@Profile = client.profile :fields => , :public => true

It seems useless to have to pass the :fields key in this case.
To fix that, you just have to modify this part of the client.rb code:
unless options[:fields].nil?
if options[:public]
path +=":public"
else
path +=":(#{options[:fields].map{|f| f.to_s.gsub("_","-")}.join(',')})"
end
end

Support new Authentication Flow

Looks like LinkedIn has a /authenticate URL instead of /authorize to support better one-click signing.

Here is what changes:
opts = {
:request_token_path => "/uas/oauth/requestToken",
:access_token_path => "/uas/oauth/accessToken",
:authorize_path => "/uas/oauth/authenticate"
}

It prevents each 'login' from making the user click the "Authorize" button which may not be bad.. perhaps this could be configurable in the construction of the client.

oauth token rejected issues

We implemented some features using linkedin 0.2.2 and everything works fine most of the time. Occasionally we are receiving OAuth::Problem token_rejected errors during the authorize_from_request method.

I have looked at Tips on Debugging OAuth Problems on LinkedIn's developer docs, but I don't think any of those are relevant.

I'm fairly new to the whole OAuth dance, has anyone else experienced anything similar?

How do I parse output from a method call to client.profile?

I used the following as an example: client.profile(:fields => "picture_url") and I got the following:

#<LinkedIn::Profile:0xb6808a98 @doc=#<Nokogiri::XML::Document:0x..fdb404506 name="document" children=[#<Nokogiri::XML::Element:0x..fdb40436c name="person" children=[#<Nokogiri::XML::Text:0x..fdb40422c "\n ">, #<Nokogiri::XML::Element:0x..fdb404204 name="picture-url" children=[#<Nokogiri::XML::Text:0x..fdb404088 "http://media.linkedin.com/mpr/mprx/0_zVjRUCzvdQg-C7R8z4VHUhCvd3Zr82R8BjdkU31k9MpDczTbEF74fiIVuqJ0LNQTDbxnH">]>, #<Nokogiri::XML::Text:0x..fdb403e94 "\n">]>]>>"

How do I access the specific element I want to reach. The class of object is LinkedIn::Profile, but I want the Nokogiri doc....

Thanks...

Rails 3 ?

Hi,

I've two questions:

  1. it seems client.profile(:id => 'gNma67_AdI', :fields => %w(first-name, last-name, headline, positions, education)) doesn't work on rails 3.
    The result (as for any valid id) is:
    LinkedIn::RateLimitExceeded in OauthController#callback (400): Bad Request - 0

  2. how can I get as much information as I want concerning the logged in user (ie profile picture per example)? I don't know how to get it's id.

Thanks in advance!

oauth issue

I'm trying to get the linkedin gem to work, but I get this error:

can't activate oauth (~> 0.3.5, runtime) for ["linkedin-0.1.7"], already activated oauth-0.4.0 for ["twitter_oauth-0.3.6"]

Anyone know the workaround?

"permission_unknown" bug or failure to understand docs

I've struggled for countless hours now trying to figure out how to get the pin (oauth_verifier) into the mix without user interaction. I thought it was easy enough just getting the oauth_verifier from params but I keep getting permission_unkown in this line:

https://github.com/wulffeld/test-linkedin-devise-omniauth/blob/master/app/controllers/connections_controller.rb#L7

If someone could point me in the right direction I'd be grateful. I have created a minimal project that uses devise, omniauth-linkedin and obviously this gem here: https://github.com/wulffeld/test-linkedin-devise-omniauth

It's mongodb based so if you have mongodb running it should work more or less out of the box - just add a config.yml file in config with the key/secret:

development:
  linkedin_key: MYKEY
  linkedin_secret: MYSECRET

On the home page click 'Sign in' then 'Sign in with Linkedin' to auth with LinkedIn.

After that just hit the /connections url and the error should appear.

If i do the example (at https://github.com/pengwynn/linkedin) where I manually get the pin it works just fine.

Status Updates Removed?

We upgraded from 0.2.2 to 0.3.2 some time ago, but have just now noticed that status updates seemed to be removed. It looks like there are commits that indicate an intent to refactor, but the 0.3.2 version seems not to contain this capability.

We had been using this gem in a larger app and are wondering if this functionality will be added back in at some point.

not escaped accentuated characters

if you try to do a search by company, for example, with accentuated characters in the company name, open-uri crashes with URI::InvalidComponentError. it seems that we should URI escape the options before passing them to open-uri.

API methods commented out ???

Hi,

I must have missed something, but the current gem version (0.3.2) seems to have all API methods commented out. I searched the gem source for the update_status method, and except for the call in the example, it's only defined in lib/linked_in/api/update_methods.rb, but everything in there is commented out!

Why is this so, and why is not the latest published gem working normally?

Id is nil for the authenticated user

After authorizing a client via authorize_from_request, the value for client.profile.id is always nil, other values like first_name are populated though.

...
LinkedIn::Client.new(linked_in['key'], linked_in['secret'])
atoken, asecret = client.authorize_from_request(token, secret, pin)
puts client.profile.id # nil
puts client.profile.first_name #'Will'

is it possible I'm not getting the full profile when authorizing this way?

Issues when using 2-0 branch

Thank you - one other quick question. I have pulled down the 2-0 branch and built a Gem that I am using, when I drill down deep enough into the groups API or call groups from Profile, I keep getting the following error:

undefined method `decorate' for nil:NilClass

Any ideas?

Thank you,
Daniel

Education's field_of_study is inside end_date?

When trying to access education's field_of_study, I found it was inside end_date as it return a hash!!

@Profile = client.profile(:fields => %w(first-name last-name positions educations location industry))

@profile.education.first.field_of_study # undefined method
@profile.education.first.end_date["field-of-study"] # very strange

Accessing field is a bit tricky :(

conflict with webrat

When I include this gem in my project, it breaks webrat in my integration tests. In my case, it is the fill_in method that generates the following error:

NoMethodError: undefined method `has_key?' for #Nokogiri::XML::Element:0x102f827a0

I've tried to hunt where the error comes from and, in webrat, file lib/webrat/core/locators/field_by_id_locator.rb in line 22 (field_elements method) there is a call to @dom.xpath(*Field.xpath_search) which returns a Nokogiri::XML::NodeSet.

Without the linkedin gem in my project:

@dom.xpath(*Field.xpath_search).first.attributes.class #=> Hash

With the linkedin gem included:

@dom.xpath(*Field.xpath_search).first.attributes.class #=> Nokogiri::XML::Element

So it's naturally expecting attributes as a Hash, but whenever I include the linkedin gem, it returns a Nokogiri::XML::Element instead.

My environment:
webrat (0.6.0)
Ruby version 1.8.7 (universal-darwin10.0)
RubyGems version 1.3.5
Rack version 1.0
Rails version 2.3.4
Active Record version 2.3.4
Active Resource version 2.3.4
Action Mailer version 2.3.4
Active Support version 2.3.4
Environment development
Database adapter sqlite3

Specifying update type in network_updates (v. 0.3.6)?

I'm probably missing something, but I'd like to be able to specify a network update type in a call to network_updates. I guessed it would be something like: client.network_updates(:type => 'SHAR')
but that returns all update types in the stream - CONN, PROF, STAT, etc. Ideally, I'd like to require multiple types such as SHAR and STAT.
Perhaps this is related to Issue #76 since specifying a count parameter doesn't seem to work either?

Escape strings inserted into XML

In case of special characters in the linkedin message subject and body the LinkedIn::Message#to_xml generates invalid xml.

Please escape subject and text in the linkedin message xml.

oauth > 0.3.5 causes error

I get Gem::Exception: can't activate oauth (~> 0.3.5, runtime) for ["linkedin-0.1.7"], already activated oauth-0.4.0 for [] because I have oauth0.4.0, does this need to hardcoded?

MultiJson::DecodeError on 401 response

Occasionally, my app seems to be receiving unexpected 401 error responses from the LinkedIn API, confusing the error-handling in the linked in gem. More specifically, the API appears to be returning an HTML payload, but the gem expects JSON.

MultiJson::DecodeError: 743: unexpected token at '<html><head><title>Apache Tomcat/6.0.32 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 401 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>This request requires HTTP authentication ().</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.32</h3></body></html>'

Here's the corresponding backtrace:

.bundle/gems/ruby/1.9.1/gems/json-1.6.0/lib/json/common.rb:148:in `parse'
.bundle/gems/ruby/1.9.1/gems/json-1.6.0/lib/json/common.rb:148:in `parse'
.bundle/gems/ruby/1.9.1/gems/multi_json-1.0.3/lib/multi_json/engines/json_gem.rb:13:in `decode'
.bundle/gems/ruby/1.9.1/gems/multi_json-1.0.3/lib/multi_json.rb:65:in `decode'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/mash.rb:9:in `from_json'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/helpers/request.rb:45:in `raise_errors'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/helpers/request.rb:16:in `get'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/api/query_methods.rb:32:in `simple_query'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/api/query_methods.rb:8:in `profile'
[PROJECT_ROOT]models/linked_in_profile.rb:14:in `find'

I think the gem needs to be more resilient in the face of this type of error.

Scoping of LinkedIn:: classes needed

Almost everywhere the subclasses liked Position, Company, etc, are used, they need to be scoped to be LinkedIn::Position, LinkedIn::Company, etc.

We have a models in our app called Company and Education, and the linkedin plugin blows up when it calls:
Company.new(@position.xpath('./company'))

because it is trying to use our model instead of LinkedIn::Company.

Bundler 1.0.10 warning message

linkedin at /home/camoedo/.rvm/gems/ruby-1.9.2-p136/bundler/gems/linkedin-3d694f1d9bb3 did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
["test/client_test.rb", "test/fixtures/blank.xml", "test/fixtures/connections.xml", "test/fixtures/error.xml", "test/fixtures/network_status_with_group.xml", "test/fixtures/network_statuses.xml", "test/fixtures/picture_updates.xml", "test/fixtures/profile.xml", "test/fixtures/profile_full.xml", "test/fixtures/profile_with_positions.xml", "test/fixtures/search.xml", "test/fixtures/status.xml", "test/oauth_test.rb", "test/test_helper.rb"] are not files

Thanks for your effort!

client.profile no output

Hi there

I'm having issues pulling anything decent out of client.profile...

All I end up with is a short hash:

LinkedIn::Profile:0x000001021cd678

I'm calling using the following in my model:

require 'linkedin'
class LinkedinToken < ConsumerToken
def index
client = LinkedIn::Client.new(LinkedinToken.consumer.key, LinkedinToken.consumer.secret)
client.authorize_from_access(token, secret)

linkedin = Linkedin::Base.new(oauth)

@client = client.profile
end
end

Interestingly, I can view the current connections and post updates fine.

Is there something stupid I'm doing wrong?

Simon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.