<commit_before>## Facebook nodejs
A simple module for querying Facebook graph api and fql

## Usage example

	var express = require('express');
	var fbgraph = require('fbgraphapi');
	var app = express();
	var http = require('http');
	var server = http.createServer(app);
	
		
	app.use(express.bodyParser());
	app.use(express.cookieParser());
	app.use(express.session({secret : "SECRET"}));
	app.use(fbgraph.auth( {
			appId : "...",
			appSecret : "...",
			redirectUri : "http://0.0.0.0:3000/"
		}));
	
	
	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);
		});
		
		req.facebook.me(function(err, me) {
		    console.log(me);
		}, 'id,name');
		
		// /me/likes
		req.facebook.my.likes(function(err, likes) {
		    console.log(likes);
		});
		
		/* Single fql query */
		req.facebook.fql('SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me())  AND is_app_user = 1', function(err, result) {
		    console.log(result);
		});
		
		/* Multiple fql queries */
		req.facebook.fql({
		    uids : 'SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) AND is_app_user = 1',
		    myapp : 'SELECT application_id, role FROM developer WHERE developer_id = me()'
		}, function(err, result) {
		    console.log(result);
		});
		res.end("Check console output");
	});
	
	server.listen(3000);

## 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.
* `scope` Permissions/scope that your application asks for, optional and default empty.

### 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

## Classes
### Facebook(accessToken)
* `accessToken` Valid access token from Facebook (oauth_token).
* `graph(path, callback)` Main method for making call to Facebook API. Path can contain only /me/likes or with params like /me/likes?limit=3
* `fql(query, callback)` Specific method for making fql query to Facebook API
* `me(callback, fields)` Specific method to get info of the logged user, same as /me when using graph-method. Fields is comma-separated for instance fields=id,name
* `getAppFriends(callback, fields)` Return friends that use your Facebook application. Fields is comma-separated.
* `my` Instance of My class

### 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`<commit_msg>example if we have a valid access token<commit_after>## Facebook nodejs
A simple module for querying Facebook graph api and fql

## Usage example

	var express = require('express');
	var fbgraph = require('fbgraphapi');
	var app = express();
	var http = require('http');
	var server = http.createServer(app);
	
		
	app.use(express.bodyParser());
	app.use(express.cookieParser());
	app.use(express.session({secret : "SECRET"}));
	app.use(fbgraph.auth( {
			appId : "...",
			appSecret : "...",
			redirectUri : "http://0.0.0.0:3000/"
		}));
	
	
	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);
		});
		
		req.facebook.me(function(err, me) {
		    console.log(me);
		}, 'id,name');
		
		// /me/likes
		req.facebook.my.likes(function(err, likes) {
		    console.log(likes);
		});
		
		/* Single fql query */
		req.facebook.fql('SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me())  AND is_app_user = 1', function(err, result) {
		    console.log(result);
		});
		
		/* Multiple fql queries */
		req.facebook.fql({
		    uids : 'SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) AND is_app_user = 1',
		    myapp : 'SELECT application_id, role FROM developer WHERE developer_id = me()'
		}, function(err, result) {
		    console.log(result);
		});
		res.end("Check console output");
	});
	
	server.listen(3000);

## 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.
* `scope` Permissions/scope that your application asks for, optional and default empty.

### 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

## Classes
### Facebook(accessToken)
* `accessToken` Valid access token from Facebook (oauth_token).
* `graph(path, callback)` Main method for making call to Facebook API. Path can contain only /me/likes or with params like /me/likes?limit=3
* `fql(query, callback)` Specific method for making fql query to Facebook API
* `me(callback, fields)` Specific method to get info of the logged user, same as /me when using graph-method. Fields is comma-separated for instance fields=id,name
* `getAppFriends(callback, fields)` Return friends that use your Facebook application. Fields is comma-separated.
* `my` Instance of My class

	// if have a valid accessToken for instance from js login
	fb = new Facebook(accessToken);
	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`
{'fraction_non_alphanumeric': 0.13525469168900806, 'fraction_numerical': 0.005093833780160858, 'mean_word_length': 3.918259723137772, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 25, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1233779', 'n_tokens_mistral': 2492, 'n_tokens_neox': 2265, 'n_words': 756}