node-social-feed-api
Simple module to fetch all social feeds and output in one simple API call.
Currently supported
- Google Plus
Install
npm install --save social-feed-api
Setup
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.
- First we will need to get the user id of the instagram user you would like to get the feed for. To do this you can go to: https://www.instagram.com/YOUR_USERNAME/?__a=1
- In a web browser, navigate to https://www.instagram.com/oauth/authorize/?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&response_type=code. It will prompt you to login with an instagram account. This is to generate an access token.
- Once logged in, click the green authorize button.
- In your console, you should see an object output. One of the fields is called access_token. If you see that, you have successfully generated your access token!
- Take that access token and place it in your applications env file or equivalent so you do not have to continually generate a new access token (Instagrams access tokens do not expire as of today).
social;
Before you begin, make sure you have an endpoint set up for your redirect uri. See full example section below.
- In a web browser, navigate to https://accounts.google.com/o/oauth2/v2/auth?redirect_uri=YOUR_REDIRECT_URI&response_type=code&client_id=YOUR_CLIENT_IDscope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fplus.login&access_type=offline
- Click "Allow"
- In your console, you should now see an object with a field "refresh_token."
- Copy that value and place it in your env file or equivalent.
- Now we will need to get the user id of the profile you want to get the feed for. In a web browser, navigate to https://www.googleapis.com/plus/v1/people/me?access_token=YOUR_ACCESS_TOKEN. You will see a field called "id." That is your google user id. Place that in your env or equivalent.
social;
Full
const social = 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 ;
Full Example (with Express)
;;;;; const app = ;app;http; const social = 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; app; app; console;