https://github.com/amachang/facebook-node-sdk 决定使用这个模块为 node.js 构建我的 facebook 集成登录,如下所示:
var express = require('express');
var Facebook = require('facebook-node-sdk');
var app = express.createServer();
app.configure(function () {
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session({ secret: 'foo bar' }));
app.use(Facebook.middleware({ appId: 'YOUR_APP_ID', secret: 'YOUR_APP_SECRET' }));
});
app.get('/', Facebook.loginRequired(), function (req, res) {
req.facebook.api('/me', function(err, user) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello, ' + user.name + '!');
});
});
如何添加额外的权限,如“电子邮件”?