Skip to content

Instantly share code, notes, and snippets.

@dangerousbeans
Created June 4, 2012 12:39
Show Gist options
  • Select an option

  • Save dangerousbeans/2868102 to your computer and use it in GitHub Desktop.

Select an option

Save dangerousbeans/2868102 to your computer and use it in GitHub Desktop.
How to get twitter account from user account number on linkedin
require 'oauth'
require 'json'
CONSUMER_KEY = "your-linkedin-app-key"
CONSUMER_SECRET = "secret-linkedin-app-thing"
consumer_options = {}
oauth_token = "derp-derp-derp-hex" # Your oauth key in hex
oauth_secret = "derp-derp-derp-more-hex" # your oauth secret key thing
consumer = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, consumer_options)
access_token = OAuth::AccessToken.new(consumer, oauth_token, oauth_secret)
# Fields you want in the response
fields = ['first-name', 'last-name', 'primary-twitter-account'].join(',')
request = "http://api.linkedin.com/v1/people/id=97587199:(#{fields})"
# Get the profile
json_txt = access_token.get(request, 'x-li-format' => 'json').body
profile = JSON.parse(json_txt)
puts "Profile data:"
puts "#{profile}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment