Giter VIP home page Giter VIP logo

faceplate's Introduction

faceplate

A Node.js wrapper for Facebook authentication and API

Usage

Use as a connect middleware

// create an express webserver
var app = require('express').createServer(
  express.bodyParser(),
  express.cookieParser(),
  require('faceplate').middleware({
    app_id: process.env.FACEBOOK_APP_ID,
    secret: process.env.FACEBOOK_SECRET,
    scope:  'user_likes,user_photos,user_photo_video_tags'
  })
);

// show friends
app.get('/friends', function(req, res) {
  req.facebook.get('/me/friends', { limit: 4 }, function(err, friends) {
    res.send('friends: ' + require('util').inspect(friends));
  });
});

// use fql to show my friends using this app
app.get('/friends_using_app', function(req, res) {
  req.facebook.fql('SELECT uid, name, is_app_user, pic_square FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1', function(err, friends_using_app) {
    res.send('friends using app: ' + require('util').inspect(friends_using_app));
  });
});

// perform multiple fql queries at once
app.get('/multiquery', function(req, res) {
  req.facebook.fql({
    likes: 'SELECT user_id, object_id, post_id FROM like WHERE user_id=me()',
    albums: 'SELECT object_id, cover_object_id, name FROM album WHERE owner=me()',
  },
  function(err, result) {
    var inspect = require('util').inspect;
    res.send('Your likes: ' + inspect(result.likes) + ', your albums: ' + inspect(result.albums) );
  });
});

// See the full signed request details
app.get('/signed_request', function(req, res) {
  res.send('Signed Request details: ' + require('util').inspect(req.facebook.signed_request));
});

License

MIT

faceplate's People

Contributors

bryanwood avatar ddollar avatar eric-wieser avatar fgnass avatar fractallian avatar machunter avatar pwagener avatar robert7k avatar stuartpb avatar zeke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

faceplate's Issues

req.facebook.me() incorrect cb

You have:

this.me = function(cb) {
if (self.token) {
self.get('/me', function(me) {
cb(me);
});
} else {
cb();
}
}

But the successful self.get function returns cb(null,result), so it should be:

this.me = function(cb) {
if (self.token) {
self.get('/me', function(err, me) {
cb(me);
});
} else {
cb();
}
}

Sorry for not just making the edit and submitting a pull request but I made a few other changes others may not want and this is a pretty minor fix :).

access_token is incorrectly called oauth_token

in FaceplateSession

  if (signed_request) {
      this.token  = signed_request.oauth_token;
      this.signed_request = signed_request;
  }

should read:

  if (signed_request) {
      this.token  = signed_request.access_token;
      this.signed_request = signed_request;
  }

current version is incompatible with express 3.x

today i tried (and failed) to use faceplate with express [email protected]
i did applied some of the migration steps to the template heroku/facebook app: express doesn't use dynamicHelpers anymore, so i think i fixed that, the server launched.
but after that it failed again, basically the Facebook object doesn't seem to be created… but i didn't dig deep.
just a heads up.

Using app tokens

There should be a method to perform API requests with the app token.
You can get by requesting this URL

/oauth/access_token
    ?grant_type=client_credentials
    &client_id=11111111
    &client_secret=9999999999

You need to do this to make calls to certain functions (such as sending a notification)

Non-json response to URLs incorrectly handled

Got this traceback just now:

access_token=AAADrWXnFBRwBAOq2HxLgnNlD2ZC... [truncated from 56 chars for security]
^
SyntaxError: Unexpected token a
    at Object.parse (native)
    at EventEmitter.<anonymous> (/home/eric/nodejs/node_modules/faceplate/index.js)

From this line

For whatever reason, a graph URL is returning a non-JSON response fo a request to /me. I'm not sure if this is documented behaviour

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.