无法使用Scribe从Linkedin API获得技能

时间:2015-09-10 12:53:00

标签: java linkedin scribe

我正在尝试使用Scribe库从LinkedIn获取技能信息。

一切正常。但它无法以XML或JSON格式打印出技能。

我在apigee中检查了网址:https://api.linkedin.com/v1/people/~:(id,skills)。它工作正常。所以我想知道代码中有什么问题。

以下是代码:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'

#To have charts on rails
gem 'chartkick'

#Turn into pdf
gem 'pdfkit'
#To read, write spreadsheets
gem 'spreadsheet', '~> 1.0.3'
#To import CSV file and spreadsheets
gem 'roo', '~> 2.1.0'
#To improve tables style
gem 'jquery-datatables-rails', '~> 3.3.0'
gem 'jquery-ui-rails'
#Pour qu'il fonctionne, le gem bcrypt doit être utilisé sous sa version 3.1.9
gem 'bcrypt', '~>3.1.7'

gem 'bootstrap-sass', '3.2.0.0'
# Use mysql as the database for Active Record
gem 'mysql2'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
#gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

此代码的输出如下:

public class LinkedInExample {
   private static final String PROTECTED_RESOURCE_URL = "https://api.linkedin.com/v1/people/~:(id,skills)";

   public static void main(String[] args) {
      OAuthService service = new ServiceBuilder()
                             .provider(LinkedInApi.class)
                             .apiKey("KEY")
                             .apiSecret("SECRET")
                             .build();
      Scanner in = new Scanner(System.in);

      // Obtain the Request Token
      Token requestToken = service.getRequestToken();

      System.out.println(service.getAuthorizationUrl(requestToken));
      System.out.println("And paste the verifier here");
      System.out.print(">>");
      Verifier verifier = new Verifier(in.nextLine());

      // Trade the Request Token and Verfier for the Access Token
      System.out.println("Trading the Request Token for an Access Token");
      Token accessToken = service.getAccessToken(requestToken, verifier);
      System.out.println("Got the Access Token!");

      // Now let's go and ask for a protected resource!
      OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
      service.signRequest(accessToken, request);
      Response response = request.send();
      System.out.println(response.getBody());

   }
}

缺少技能信息。

0 个答案:

没有答案