All Projects → sourcetoad → node-social-feed-api

sourcetoad / node-social-feed-api

Licence: MIT license
Aggregates social media feeds and outputs them to use in an API

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to node-social-feed-api

SocialAuth
No description or website provided.
Stars: ✭ 35 (+75%)
Mutual labels:  twitter-api, instagram-api
Laravel Facebook Ads
Facebook & Instagram Ads API for Laravel
Stars: ✭ 87 (+335%)
Mutual labels:  facebook-api, instagram-api
Python Facebook
A simple Python wrapper for facebook graph api ✨ 🍰 ✨ .
Stars: ✭ 109 (+445%)
Mutual labels:  facebook-api, instagram-api
GraphiPy
GraphiPy: Universal Social Data Extractor
Stars: ✭ 61 (+205%)
Mutual labels:  twitter-api, facebook-api
Book Socialmediaminingpython
Companion code for the book "Mastering Social Media Mining with Python"
Stars: ✭ 462 (+2210%)
Mutual labels:  twitter-api, facebook-api
grasp
Essential NLP & ML, short & fast pure Python code
Stars: ✭ 58 (+190%)
Mutual labels:  twitter-api, google-api
Albert
这个是我个人网站的项目,欢迎贡献代码,力求能够应用到实际工作中java相关的大多数技术栈。有兴趣请Star一下,非常感谢。qq交流群:587577705 这个项目将不断地更新!生产环境:
Stars: ✭ 168 (+740%)
Mutual labels:  twitter-api, google-api
social-post-api
Social Media API: Automate Posting and Analytics to Social Networks like Instagram, TikTok, Twitter, Facebook, LinkedIn, Reddit, YouTube, and Telegram
Stars: ✭ 38 (+90%)
Mutual labels:  facebook-api, instagram-api
JFXGoogleDrive
A JavaFX Google Drive Client (For Demonstration Purposes Only).
Stars: ✭ 29 (+45%)
Mutual labels:  google-api
FacebookMessengerActivity
Share with Facebook Messenger App.
Stars: ✭ 16 (-20%)
Mutual labels:  facebook-api
twpy
Twitter High level scraper for humans.
Stars: ✭ 58 (+190%)
Mutual labels:  twitter-api
follow-sync
Re-synchronize your Instagram following list (or: unfollow everyone who doesn't follow you back)
Stars: ✭ 18 (-10%)
Mutual labels:  instagram-api
weltschmerz
Weltschmerz by age - "I am X years old and... [Google autocomplete]"
Stars: ✭ 23 (+15%)
Mutual labels:  google-api
Instagram-Auto-Pilot
Automate common Instagram activities such as following, unfollowing, commenting and reposting images from instagram accounts.
Stars: ✭ 50 (+150%)
Mutual labels:  instagram-api
viewtweets
🙈🐵 View tweets (timelines, favorites, searches) in Rstudio 🐵🙈
Stars: ✭ 21 (+5%)
Mutual labels:  twitter-api
instagram
Php instagram library. With this library, you can use many of the same features in the mobile application.
Stars: ✭ 45 (+125%)
Mutual labels:  instagram-api
twitter-php-ads-sdk
A Twitter supported and maintained Ads API SDK for PHP.
Stars: ✭ 51 (+155%)
Mutual labels:  twitter-api
py translator
The end goal is a simple application for translating text in the terminal. Text can be generated interactively or programmatically in the shell environment.
Stars: ✭ 45 (+125%)
Mutual labels:  google-api
large-video-upload-python
Sample Python code for uploading video up to 140 seconds and/or up to 512Mb.
Stars: ✭ 109 (+445%)
Mutual labels:  twitter-api
cMaps
🎨 Control options and customization of the Google Maps colors, just 1,7 KB.
Stars: ✭ 14 (-30%)
Mutual labels:  google-api

node-social-feed-api

Simple module to fetch all social feeds and output in one simple API call.

NPM

Build Status

Currently supported

  • Facebook
  • Twitter
  • Instagram
  • 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.

Instagram

Before you begin, make sure you have an endpoint set up for your redirect uri. See full example section below.

  1. 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
  2. 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.
  3. Once logged in, click the green authorize button.
  4. 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!
  5. 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.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.' });
});
Google

Before you begin, make sure you have an endpoint set up for your redirect uri. See full example section below.

  1. 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
  2. Click "Allow"
  3. In your console, you should now see an object with a field "refresh_token."
  4. Copy that value and place it in your env file or equivalent.
  5. 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.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.' });
});
Full
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,
  },
});

Full Example (with Express)

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');
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].