node-linkedin 连接问题
node-linkedin coonection issue
我在尝试实现与 node-linkedin 的连接示例时遇到问题。
我总是得到这个错误:{ errorCode: 0, message: 'Invalid access token.', requestId: 'IN32C163DK', status: 401, timestamp: 1459554255669 }
这是我的代码:
var nodemailer = require('nodemailer');
var Linkedin = require('node-linkedin')('app-id', 'secret', 'callback');
router.get('/linkedin', function(req, res) {
console.log("hello linkedin");
var linkedin = Linkedin.init('my_access_token');
linkedin.companies_search.name('facebook', 1, function(err, company) {
console.log(company);
name = company.companies.values[0].name;
desc = company.companies.values[0].description;
industry = company.companies.values[0].industries.values[0].name;
city = company.companies.values[0].locations.values[0].address.city;
websiteUrl = company.companies.values[0].websiteUrl;
});
});
这里是包的link:https://github.com/ArkeologeN/node-linkedin
你能帮我解决这个问题吗?
谢谢
我修好了。
router.get('/linkedin', function(req, res) {
Linkedin.auth.getAccessToken(res, req.query.code, req.query.state, function(err, results) {
if ( err )
return console.error(err);
var linkedin = Linkedin.init(results.access_token || results.accessToken);
});
linkedin.companies_search.name('facebook', 1, function(err, company) {
console.log(company);
name = company.companies.values[0].name;
console.log(name);
});
});
});
我在尝试实现与 node-linkedin 的连接示例时遇到问题。
我总是得到这个错误:{ errorCode: 0, message: 'Invalid access token.', requestId: 'IN32C163DK', status: 401, timestamp: 1459554255669 }
这是我的代码:
var nodemailer = require('nodemailer');
var Linkedin = require('node-linkedin')('app-id', 'secret', 'callback');
router.get('/linkedin', function(req, res) {
console.log("hello linkedin");
var linkedin = Linkedin.init('my_access_token');
linkedin.companies_search.name('facebook', 1, function(err, company) {
console.log(company);
name = company.companies.values[0].name;
desc = company.companies.values[0].description;
industry = company.companies.values[0].industries.values[0].name;
city = company.companies.values[0].locations.values[0].address.city;
websiteUrl = company.companies.values[0].websiteUrl;
});
});
这里是包的link:https://github.com/ArkeologeN/node-linkedin
你能帮我解决这个问题吗?
谢谢
我修好了。
router.get('/linkedin', function(req, res) {
Linkedin.auth.getAccessToken(res, req.query.code, req.query.state, function(err, results) {
if ( err )
return console.error(err);
var linkedin = Linkedin.init(results.access_token || results.accessToken);
});
linkedin.companies_search.name('facebook', 1, function(err, company) {
console.log(company);
name = company.companies.values[0].name;
console.log(name);
});
});
});