Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
social-feed-api
Advanced tools
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
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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.