Add LinkedIn API example route and controller
This commit is contained in:
1
app.js
1
app.js
@ -132,6 +132,7 @@ app.get('/api/github', passportConf.isAuthenticated, passportConf.isAuthorized,
|
||||
app.get('/api/twitter', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.getTwitter);
|
||||
app.get('/api/venmo', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.getVenmo);
|
||||
app.post('/api/venmo', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.postVenmo);
|
||||
app.get('/api/linkedin', apiController.getLinkedin);
|
||||
|
||||
/**
|
||||
* OAuth routes for sign-in.
|
||||
|
@ -14,6 +14,7 @@ var Github = require('github-api');
|
||||
var Twit = require('twit');
|
||||
var paypal = require('paypal-rest-sdk');
|
||||
var twilio = require('twilio')(secrets.twilio.sid, secrets.twilio.token);
|
||||
var Linkedin = require('node-linkedin')(secrets.linkedin.clientID, secrets.linkedin.clientSecret, secrets.linkedin.callbackURL);
|
||||
|
||||
/**
|
||||
* GET /api
|
||||
@ -482,3 +483,45 @@ exports.postVenmo = function(req, res, next) {
|
||||
res.redirect('/api/venmo');
|
||||
});
|
||||
};
|
||||
|
||||
exports.getLinkedin = function(req, res, next) {
|
||||
var token = _.findWhere(req.user.tokens, { kind: 'linkedin' });
|
||||
var linkedin = Linkedin.init(token);
|
||||
|
||||
async.parallel({
|
||||
profile: function(done) {
|
||||
linkedin.people.me(function(err, $in) {
|
||||
console.log($in);
|
||||
done(err, $in);
|
||||
});
|
||||
},
|
||||
profileById: function(doone) {
|
||||
linkedin.people.url('linkedin_id', function(err, $in) {
|
||||
console.log($in);
|
||||
done(err, $in);
|
||||
});
|
||||
},
|
||||
connections: function(done) {
|
||||
linkedin.connections.me(function(err, $in) {
|
||||
console.log($in);
|
||||
done(err, $in);
|
||||
});
|
||||
},
|
||||
companies: function(done) {
|
||||
linkedin.companies.me(function(err, $in) {
|
||||
console.log($in);
|
||||
done(err, $in);
|
||||
});
|
||||
}
|
||||
},
|
||||
function(err, results) {
|
||||
if (err) return next(err);
|
||||
res.render('api/linkedin', {
|
||||
title: 'LinkedIn API',
|
||||
profile: results.profile,
|
||||
profileById: results.profileById,
|
||||
connections: results.connections,
|
||||
companies: results.companies
|
||||
});
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user