-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
33 lines (25 loc) · 841 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var Singly = require('./lib');
var express = require('express');
var clientID = process.argv[2];
var clientSecret = process.argv[3];
var singly = new Singly(clientID, clientSecret, 'http://localhost:8044/callback');
var app = express.createServer();
var accessToken;
app.get('/', function(req, res) {
res.redirect(singly.getAuthorizeURL('facebook'));
});
app.get('/callback', function(req, res) {
singly.getAccessToken(req.param('code'), function(err, access_token) {
accessToken = access_token;
res.redirect('/all');
});
});
app.get('/all', function(req, res) {
if (!accessToken) return res.redirect('/');
singly.apiCall('/types/all', {access_token:accessToken}, function(err, resp) {
if(err) return res.send(err, 500);
res.send(resp);
});
});
app.listen(8044);
console.log('open http://localhost:8044');