Added Instagram API Example
This commit is contained in:
@ -16,6 +16,7 @@ var stripe = require('stripe')(secrets.stripe.apiKey);
|
|||||||
var twilio = require('twilio')(secrets.twilio.sid, secrets.twilio.token);
|
var twilio = require('twilio')(secrets.twilio.sid, secrets.twilio.token);
|
||||||
var Linkedin = require('node-linkedin')(secrets.linkedin.clientID, secrets.linkedin.clientSecret, secrets.linkedin.callbackURL);
|
var Linkedin = require('node-linkedin')(secrets.linkedin.clientID, secrets.linkedin.clientSecret, secrets.linkedin.callbackURL);
|
||||||
var clockwork = require('clockwork')({key: secrets.clockwork.apiKey});
|
var clockwork = require('clockwork')({key: secrets.clockwork.apiKey});
|
||||||
|
var ig = require('instagram-node').instagram();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /api
|
* GET /api
|
||||||
@ -500,3 +501,56 @@ exports.getLinkedin = function(req, res, next) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /api/instagram
|
||||||
|
* Instagram API example.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.getInstagram = function(req, res, next) {
|
||||||
|
var token = _.findWhere(req.user.tokens, { kind: 'instagram' });
|
||||||
|
|
||||||
|
ig.use({ access_token: token });
|
||||||
|
ig.use({ client_id: secrets.instagram.clientID, client_secret: secrets.instagram.clientSecret });
|
||||||
|
|
||||||
|
async.parallel({
|
||||||
|
searchByUsername: function(done) {
|
||||||
|
ig.user_search('lisa_veronica', function(err, users, limit) {
|
||||||
|
done(err, users);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchByUserId: function(done) {
|
||||||
|
ig.user('175948269', function(err, user) {
|
||||||
|
console.log(user);
|
||||||
|
done(err, user);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
popularImages: function(done) {
|
||||||
|
ig.media_popular(function(err, medias) {
|
||||||
|
done(err, medias);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function(err, results) {
|
||||||
|
res.render('api/instagram', {
|
||||||
|
title: 'Instagram API',
|
||||||
|
usernames: results.searchByUsername,
|
||||||
|
userById: results.searchByUserId,
|
||||||
|
popularImages: results.popularImages
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.postInstagram = function(req, res, next) {
|
||||||
|
var token = _.findWhere(req.user.tokens, { kind: 'instagram' });
|
||||||
|
|
||||||
|
ig.use({ access_token: token });
|
||||||
|
ig.use({ client_id: secrets.instagram.clientID, client_secret: secrets.instagram.clientSecret });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ig.user_search('13reasons', function(err, users, limit) {
|
||||||
|
console.log(users);
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
@ -30,6 +30,11 @@ block content
|
|||||||
.panel-body
|
.panel-body
|
||||||
img(src='https://github.global.ssl.fastly.net/images/modules/logos_page/Octocat.png', height=40)
|
img(src='https://github.global.ssl.fastly.net/images/modules/logos_page/Octocat.png', height=40)
|
||||||
a(href='/api/github') GitHub
|
a(href='/api/github') GitHub
|
||||||
|
.col-sm-4
|
||||||
|
.panel.panel-default
|
||||||
|
.panel-body
|
||||||
|
img(src='http://aweebitirish.com/wp-content/uploads/2014/03/instagram-app-icon-vector.png', height=40)
|
||||||
|
a(href='/api/instagram') Instagram
|
||||||
.col-sm-4
|
.col-sm-4
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
.panel-body
|
.panel-body
|
||||||
|
60
views/api/instagram.jade
Normal file
60
views/api/instagram.jade
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
extends ../layout
|
||||||
|
|
||||||
|
block content
|
||||||
|
.page-header
|
||||||
|
h2
|
||||||
|
i.fa.fa-instagram
|
||||||
|
| Instagram API
|
||||||
|
.btn-group.btn-group-justified
|
||||||
|
a.btn.btn-primary(href='http://instagram.com/developer/', target='_blank')
|
||||||
|
i.fa.fa-check-square-o
|
||||||
|
| Overview
|
||||||
|
a.btn.btn-primary(href='https://github.com/teleportd/instagram-node', target='_blank')
|
||||||
|
i.fa.fa-laptop
|
||||||
|
| Node-Instagram Library
|
||||||
|
a.btn.btn-primary(href='http://instagram.com/developer/endpoints/', target='_blank')
|
||||||
|
i.fa.fa-code-fork
|
||||||
|
| API Endpoints
|
||||||
|
|
||||||
|
br
|
||||||
|
p.lead Username Search for
|
||||||
|
strong lisa_veronica
|
||||||
|
table.table.table-hover.table-bordered
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
th Picture
|
||||||
|
th Username
|
||||||
|
th Full Name
|
||||||
|
th Bio
|
||||||
|
tbody
|
||||||
|
for user in usernames
|
||||||
|
tr
|
||||||
|
td
|
||||||
|
img(src='#{user.profile_picture}', width='75', height='75')
|
||||||
|
td= user.username
|
||||||
|
td= user.full_name
|
||||||
|
td= user.bio
|
||||||
|
|
||||||
|
hr
|
||||||
|
p.lead User Search for ID
|
||||||
|
strong 175948269
|
||||||
|
|
||||||
|
|
||||||
|
img.thumbnail(src='#{userById.profile_picture}', width='75', height='75')
|
||||||
|
p
|
||||||
|
a(href='http://instagram.com/#{userById.username}')
|
||||||
|
strong #{userById.full_name}
|
||||||
|
br
|
||||||
|
| #{userById.bio}
|
||||||
|
|
||||||
|
hr
|
||||||
|
p.lead Popular Images on Instagram
|
||||||
|
.row
|
||||||
|
for image in popularImages
|
||||||
|
.col-xs-3
|
||||||
|
a.thumbnail(href='#{image.link}')
|
||||||
|
img(src='#{image.images.standard_resolution.url}', height='320px')
|
||||||
|
div.facebook-caption
|
||||||
|
i.fa.fa-heart
|
||||||
|
| #{image.likes.count}
|
||||||
|
|
Reference in New Issue
Block a user