有谁知道node.js linkedin API示例?

Sim*_*ley 11 linkedin node.js

我想用node.js做一些LinkedIn API编码.有谁知道实现LinkedIn oauth的示例node.js应用程序?

谢谢

Jam*_*111 6

我一直在使用node-linkedin,非常易于安装,你可以用它做的一切......这看起来也有很多比5票的答案更有前途.

快速简便的设置示例:

var Linkedin = require('node-linkedin')('app-id', 'secret'); // Get app-id + secret from your LinkedIn developer account
Run Code Online (Sandbox Code Playgroud)

使用令牌初始化一个linkedin类,例如您从前端收到的oauth2令牌.this.token =从前端解析为我的api的令牌.

var linkedin = Linkedin.init(this.token); // this.token = client token.
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的承诺的电话:

return new Promise( (fullfil, reject) => {
      linkedin.people.me( (err, user) => {
        console.log (user, "All user data attached to this.token");
        let resp = {response: user, error: null};
        if (err) resp = {response: null, error: err};
        else {
          this.email = user.emailAddress;
          this.id = user.id;
        }

        fullfil(resp)
      });
});
Run Code Online (Sandbox Code Playgroud)

没有承诺它看起来像这样:

linkedin.people.me( (err, user) => { console.log (user); });
Run Code Online (Sandbox Code Playgroud)


小智 0

http://github.com/ciaranj/node-oauth/tree/master/examples有一些使用 OAuth 的服务的示例。YMMV。