LinkedIn node.js 中的 Id 获取人员



我想从 Node.js LinkedIn 的 API 中获取一些数据。我 https://www.npmjs.com/package/node-linkedin 遵循了本教程,并编写了这个程序,该程序应该在回调中将数据发送到控制台。

var Linkedin = require('node-linkedin')('XXX', 'XXX', 'http://localhost:3000/oauth/linkedin/callback');
var express = require('express');
var app = express()
    // Initialize 
var scope = ['r_basicprofile', 'r_emailaddress'];

var linkedinVariables = {
    'accessToken': null,
    'client': null
}
app.get('/oauth/linkedin', function(req, res) {
    // This will ask for permisssions etc and redirect to callback url. 
    Linkedin.auth.authorize(res, scope);
});
app.get('/oauth/linkedin/callback', function(req, res) {
    Linkedin.auth.getAccessToken(res, req.query.code, req.query.state, function(err, results) {
        if (err)
            return console.error(err);
        console.log(results);
        linkedinVariables.accessToken = results.access_token;
        console.log("ACCESS TOKEN IS ", linkedinVariables.accessToken);
        linkedinVariables.client = Linkedin.init(linkedinVariables.accessToken);
    /*  linkedinVariables.client.people.me(function(err, $in) {
            console.log($in);
        });*/
/*linkedinVariables.client.people.me('linkedin_id', ['id', 'first-name', 'last-name'], function(err, $in) {
    // Loads the profile by id.
    console.log($in);
});*/
        linkedinVariables.client.people.id('HM3nX8nJD6', function(err, $in) {
            console.log($in)
        });
        // return res.redirect('/');
    });
});
app.listen(3000);

现在这个程序工作正常,我得到以下行的数据:

linkedinVariables.client.people.me('linkedin_id', ['id', 'first-name', 'last-name'], function(err, $in) {
        // Loads the profile by id.
        console.log($in);
    });

这在我的控制台中为我提供了一个 JSON 响应,但按照教程,我应该通过 ID 获取有关公司和人员的其他信息,但即使我输入自己的 ID 来获取自己的信息,响应也是空白的。我的代码有问题还是LinkedIn拒绝所有获取请求?

使用这个

var scope = ['r_basicprofile', 'r_fullprofile', 'r_emailaddress', 'r_network', 'r_contactinfo', 'rw_nus', 'rw_groups', 'w_messages'];

而不是

var scope = ['r_basicprofile', 'r_emailaddress'];

最新更新