Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
social-feed-api
Advanced tools
Readme
Simple module to fetch all social feeds and output in one simple API call.
npm install --save social-feed-api
Instagram and Google both require user-specific access tokens, thus requiring special setup. See full example below for more specific examples.
Before you begin, make sure you have an endpoint set up for your redirect uri. See full example section below.
social.initializeInstagram('YOUR_CODE_FROM_CALLBACK_URI')
.then(response => {
console.log(response);
instaAccessToken = response.access_token;
res.status(201).json({ message: 'Access token generated successfully!' });
}, () => {
res.status(400).json({ message: 'Error occurred generating Instagram access token.' });
});
Before you begin, make sure you have an endpoint set up for your redirect uri. See full example section below.
social.initializeGoogle(req.query.code)
.then(response => {
console.log(response);
gAccessToken = response.access_token;
res.status(201).json({ message: 'Access token generated successfully!' });
}, () => {
res.status(400).json({ message: 'Error occurred generating google access token.' });
});
const social = new SocialFeed({
facebook: {
appId: 'YOUR_FB_APP_ID',
appSecret: 'YOUR_FB_APP_SECRET',
pageId: 'PAGE_ID_YOU_ARE_FETCHING',
image: {
height: 100,
width: 100,
},
},
twitter: {
consumerKey: 'YOUR_TWITTER_CONSUMER_KEY',
consumerSecret: 'YOUR_TWITTER_CONSUMER_SECRET',
accessTokenKey: 'YOUR_TWITTER_ACCESS_TOKEN_KEY',
accessTokenSecret: 'YOUR_TWITTER_ACCESS_TOKEN_SECRET',
screenName: 'HANDLE_YOU_ARE_FETCHING',
options: {
excludeReplies: true,
count: 50,
include_rts: false,
},
},
instagram: {
clientId: instagramClientId,
clientSecret: instagramClientSecret,
redirectURI: instagramRedirectURI,
userId: instagramUserId,
accessToken: instagramAccessToken,
},
google: {
clientId: googleClientId,
clientSecret: googleClientSecret,
userId: googleUserId,
redirectURI: googleRedirectURI,
refreshToken: googleRefreshToken,
},
});
import express from 'express';
import bodyParser from 'body-parser';
import http from 'http';
import SocialFeed from 'social-feed-api';
import {
fbAppId,
fbAppSecret,
fbPageId,
twitterConsumerKey,
twitterConsumerSecret,
twitterAccessTokenKey,
twitterAccessTokenSecret,
twitterScreenName,
instagramClientId,
instagramClientSecret,
instagramRedirectURI,
instagramAccessToken,
instagramUserId,
googleClientId,
googleClientSecret,
googleRedirectURI,
googleUserId,
googleRefreshToken,
port,
env,
} from './env';
const app = express();
app.use(bodyParser.json({ type: 'application/*+json' }));
http.createServer(app).listen(port);
const social = new SocialFeed({
facebook: {
appId: fbAppId,
appSecret: fbAppSecret,
pageId: fbPageId,
image: {
height: 100,
width: 100,
},
},
twitter: {
consumerKey: twitterConsumerKey,
consumerSecret: twitterConsumerSecret,
accessTokenKey: twitterAccessTokenKey,
accessTokenSecret: twitterAccessTokenSecret,
screenName: twitterScreenName,
options: {
excludeReplies: true,
count: 50,
include_rts: false,
},
},
instagram: {
clientId: instagramClientId,
clientSecret: instagramClientSecret,
redirectURI: instagramRedirectURI,
userId: instagramUserId,
accessToken: instagramAccessToken,
},
google: {
clientId: googleClientId,
clientSecret: googleClientSecret,
userId: googleUserId,
redirectURI: googleRedirectURI,
refreshToken: googleRefreshToken,
},
});
let instaAccessToken = instagramAccessToken || '';
app.get('/v1/socialFeed', (req, res) => {
const accessTokens = {
instagram: instaAccessToken,
google: gAccessToken,
};
social.getFeeds(accessTokens)
.then(response => {
res.status(200).json({ response });
}, () => {
res.status(400).json({ error: 'There was an error fetching feeds' });
});
});
app.get('/v1/socialFeed', (req, res) => {
social.getFeeds()
.then(response => {
res.status(200).json({ response });
}, err => {
console.error(err);
res.status(400).json({ error: 'There was an error fetching feeds' });
});
});
app.get('/v1/googleRedirect', (req, res) => {
if (googleRefreshToken) res.status(400).json({ message: 'Refresh token already generated' });
if (req.query.code) {
if (!googleRefreshToken) {
social.initializeGoogle(req.query.code)
.then(response => {
console.log(response);
res.status(201).json({ message: 'Google tokens generated successfully!' });
}, () => {
res.status(400).json({ message: 'Error occurred generating google tokens.' });
});
}
} else {
res.status(400).json({ error: 'An error occurred' });
}
});
console.log('STARTING SERVER');
FAQs
Aggregates social media feeds and outputs them to use in an API
The npm package social-feed-api receives a total of 0 weekly downloads. As such, social-feed-api popularity was classified as not popular.
We found that social-feed-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.