All Projects → vanng822 → facebook-nodejs

vanng822 / facebook-nodejs

Licence: MIT license
Nodejs module for Facebook api

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to facebook-nodejs

facebook-go-sdk
A very simple and easy-to-use Facebook SDK for Golang.
Stars: ✭ 18 (-30.77%)
Mutual labels:  facebook-api, graph-api
fauna-gql-upload
A tool for managing your FaunaDB database using files. Create resources such as functions by simply creating a new file.
Stars: ✭ 45 (+73.08%)
Mutual labels:  fql
Fluent Facebook
A laravel 5 package for reading and writing to facebook graph object with ease in laravelish syntax
Stars: ✭ 49 (+88.46%)
Mutual labels:  facebook-api
Facebook Js Ads Sdk
[DEPRECATED] OFFICIAL FACEBOOK SDK: https://github.com/facebook/facebook-nodejs-ads-sdk
Stars: ✭ 140 (+438.46%)
Mutual labels:  facebook-api
Laravel Facebook Ads
Facebook & Instagram Ads API for Laravel
Stars: ✭ 87 (+234.62%)
Mutual labels:  facebook-api
Keras fb
Enable Keras to send real-time training info to your Messenger account
Stars: ✭ 186 (+615.38%)
Mutual labels:  facebook-api
Zuck
Facebook Graph API wrapper for Elixir
Stars: ✭ 12 (-53.85%)
Mutual labels:  facebook-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 (+46.15%)
Mutual labels:  facebook-api
Facebooktoolkit
a tool to get Facebook data, and some Facebook bots, and extra tools found on Facebook Toolkit ++.
Stars: ✭ 227 (+773.08%)
Mutual labels:  facebook-api
Facebook
📨 Facebook Notifications Channel for Laravel
Stars: ✭ 120 (+361.54%)
Mutual labels:  facebook-api
Python Facebook
A simple Python wrapper for facebook graph api ✨ 🍰 ✨ .
Stars: ✭ 109 (+319.23%)
Mutual labels:  facebook-api
Devil
Devil is a tool that is basically made for facebook to Hack target accounts , BruteForce Attack , grab friendlist accounts , yahoo chacker , Facbook Friend information gathering tool , auto likes reactions & much more i hope you enjoy this tool i'm not responsible if you use this tool for any illegal purpose
Stars: ✭ 88 (+238.46%)
Mutual labels:  facebook-api
Facebookimagepicker
FacebookImagePicker is Facebook album photo picker written in Swift.
Stars: ✭ 220 (+746.15%)
Mutual labels:  facebook-api
Facebook Graph Api
Get data using facebook graph API - V3.2
Stars: ✭ 73 (+180.77%)
Mutual labels:  facebook-api
next-fauna-auth
Implemented cookie-based user authentication in a Next.js, FaunaDB and GraphQL app
Stars: ✭ 29 (+11.54%)
Mutual labels:  fql
Pizza Delivery
university project : Android pizza delivery app
Stars: ✭ 32 (+23.08%)
Mutual labels:  facebook-api
Facebook Export
Tools to help administer your Facebook groups
Stars: ✭ 96 (+269.23%)
Mutual labels:  facebook-api
J2team Community
Join our group to see more
Stars: ✭ 172 (+561.54%)
Mutual labels:  facebook-api
jgrapht
Master repository for the JGraphT project
Stars: ✭ 2,259 (+8588.46%)
Mutual labels:  graph-api
faunadb-fql-lib
No description or website provided.
Stars: ✭ 83 (+219.23%)
Mutual labels:  fql

Facebook nodejs

A simple module for querying Facebook graph api and fql

Usage example

// run first: npm install express fbgraphapi body-parser cookie-parser express-session
const express = require('express');
const fbgraph = require('fbgraphapi');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const session = require('express-session');

const app = express();
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser())
app.use(session({
  secret: 'keyboard cat',
  resave: false,
  saveUninitialized: true,
  cookie: { secure: false }
}))

app.use(fbgraph.auth( {
		appId : "...",
		appSecret : "...",
		redirectUri : "http://0.0.0.0:3000/",
		apiVersion: "v2.9",
		skipUrlPatterns: ["/favicon.ico"]
	}));

app.get('/login', function(req, res) {
	console.log('Start login');
	fbgraph.redirectLoginForm(req, res);
});

app.get('/', function(req, res) {
	if (!req.hasOwnProperty('facebook')) {
		console.log('You are not logged in');
		return res.redirect('/login');
	}
	/* See http://developers.facebook.com/docs/reference/api/ for more */
	req.facebook.graph('/me', function(err, me) {
	    console.log(me);
	});

	req.facebook.graph('/me?fields=id,name', function(err, me) {
	    console.log(me);
	});

	req.facebook.me(function(err, me) {
	    console.log(me);
	});

	// /me/likes
	req.facebook.my.likes(function(err, likes) {
	    console.log(likes);
	});

	res.end("Check console output");
});

app.listen(3000);

Or if have a valid access token for instance from javascript fb connect

var fb = new fbgraph.Facebook(accessToken, 'v2.2');
fb.me(function(err, me) {
	console.log(me);
});

Or do stuff on behalf of the app or user with granted permissions

var fb = new fbgraph.Facebook(fbgraph.getAppId() + '|' + fbgraph.getAppSecret());
fb.post('/{user-id}/feed', {message: 'Hello world'},function(err, res) {
	console.log(err, res);
});

Facebook API reference

Visit the links bellow for API documentation of Facebook API https://developers.facebook.com/docs/graph-api/using-graph-api

Methods

auth(config)

config is an object with those properties

  • appId Facebook application Id
  • appSecret Secret hash key generated by Facebook
  • redirectUri The url to redirect to when user logged in.
  • apiVersion Which api version to use, example v2.2
  • scope Permissions/scope that your application asks for, optional and default empty.
  • skipUrlPatterns Array of patterns which to not apply authentication on. They can be regexp or string. If string a regexp will be created with wildcard appending at the end. If you want an exact url make sure specify regexp.

authenticate(req, res, next)

This method is returned when calling auth() above. When loggin is successfull it will assign a Facebook instance to req (see example above).

redirectLoginForm(req, res)

This method will redirect user to Facebook login form.

destroySession(req, res, clearCookie)

This method is for logging out user or for any reason want to clear user's logged-in info

getAppId()

return app id, set via auth()

getAppSecret()

return app secret, set via auth()

Classes

Facebook(accessToken, apiVersion)

Usage: if have a valid accessToken for instance from js login

var fb = new Facebook(accessToken, 'v2.2');
fb.me(function(err, me) {
	console.log(me);
});

My(facebook)

This class uses internally to create object my (property in Facebook). This object wrap the me-object. Each connection type is a method. This means that you can make a call like

req.facebook.my.friends(function(err, friends) {
	console.log(friends)
});

// OR for checkins
req.facebook.my.checkins(function(err, checkins) {
	console.log(checkins)
});

Supported connection types are:

  • friends
  • feed
  • likes
  • movies
  • music
  • books
  • albums
  • notes
  • permissions
  • photos
  • videos
  • events
  • groups
  • checkins
  • locations

If you can not find a connection that Facebook has but not here you can use connection-method

req.facebook.my.connection('{connection type}', function(err, result) {
	console.log(result)
});
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].