-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
45 lines (33 loc) · 1.08 KB
/
example.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
34
35
36
37
38
39
40
41
42
43
44
45
var api_key = 'db2192a62694d7b6de827abb1e80a9dd',
api_secret = '18fbf383fac9f8c8',
http = require('http'),
stdin = process.stdin,
RememberTheMilk = require('../../rtm.js');
rtm = new RememberTheMilk(api_key, api_secret, 'delete');
rtm.get('rtm.auth.getFrob', function(resp){
frob = resp.rsp.frob;
var authUrl = rtm.getAuthUrl(frob);
console.log('Please visit the following URL in your browser to authenticate:\n');
console.log(authUrl, '\n');
console.log('After authenticating, press any key to resume...');
stdin.resume();
stdin.on('data', function() {
rtm.get('rtm.auth.getToken', {frob: frob}, function(resp){
if (!resp.rsp.auth) {
console.log('Auth token not found. Did you authenticate?\n');
process.exit(1);
}
rtm.auth_token = resp.rsp.auth.token;
console.log('Lists:');
rtm.get('rtm.lists.getList', function(resp){
var i, list;
for (i = 0; i < resp.rsp.lists.list.length; i++) {
list = resp.rsp.lists.list[i];
console.log(list.name + ' (id: ' + list.id + ')');
}
console.log();
process.exit();
});
});
});
});