app.js 1.88 KB
var express = require('express');
var app = express();

var fs = require('fs');

app.use(function(req, res, next){
  console.log('%s %s', req.method, req.url);
  next();
});

app.use(express.static(__dirname + '/public'));
app.use(express.bodyParser());

//index
app.get('/',function(req,res)
{
  var html = '<!doctype html><html><head><title>U Up Up!</title> <meta name="google-site-verification" content="cQoYR2ncKEPvT919ZOGe_-X34kitFX8ijFoJ1sdAnA0" /><link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Lemon"> <head><body style="background:#000 url(http://farm8.staticflickr.com/7292/8825786798_883bee009d_o.jpg) center 0 no-repeat;color:#fff;background-size:100%"><h1 style="font-family:Lemon;text-align:center">U Up Up!</h1></body></html>'
  res.setHeader('Content-Type','text/html');
  res.setHeader('Content-length',html.length);
  res.end(html);
});


var FB = require('fb');
app.get('/fb',function(req,res)
{
	var data =  req.param('data');
	data = JSON.parse(data);
	var method = data.method;
	var fields = {fields:data.fields};
        if(data.limit)
        {
           fields.offset = data.offset;
           fields.limit = data.limit;
        }
	var at = data.accessToken
	FB.setAccessToken(at);
        console.log(fields);
	if(data.fields)
	{
          FB.api(method,fields,function (resp) 
	  {
	          console.log(resp);
         	  res.send(resp);
	  });
	}
	else
	{
          FB.api(method,function (resp) 
	  {
		 console.log(resp);
                 res.send(resp);
	  });
	}
});

app.post('/fb',function(req,res)
{
    var data =  req.body.data;
    data = JSON.parse(data);
    console.log(data);
    var method = data.method;
    var body = data.body;
    var at = data.accessToken
    FB.setAccessToken(at);
    FB.api(method,'post',body,function (resp) 
    {
	 console.log(resp);
          res.send(resp);
    });
});


app.listen(80);




console.log('OK!');