-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
40 lines (32 loc) · 1.18 KB
/
example.js
File metadata and controls
40 lines (32 loc) · 1.18 KB
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
var browser = require('openurl');
var cloudsponge = require('./cloudsponge');
var AUTHENTICATION = {domain_key: 'YRMBHYC3DRPEK3LUSCYK', domain_password: 'zgIER11nFCWMAGM'};
/// Using Callbacks
// cloudsponge.Importer.authorize('gmail', AUTHENTICATION, function(response){
// console.log("open browser at:", response.contacts.consent_url)
// browser.open(response.contacts.consent_url);
// response.events.get(function() {
// response.contacts.get(function(collection){
// console.log("OK")
// // for (var key in collection) {
// // if (collection.hasOwnProperty(key)) {
// // console.log(collection[key])
// // }
// // }
// });
// });
// });
/// Using EventEmitter
var importer = cloudsponge.Importer;
importer.import("gmail", AUTHENTICATION);
importer.on('Initialized', function(consent){
browser.open(consent.url);
importer.consent.getEvents(consent.import_id, function(contacts){
console.log("rtn:::", contacts);
});
});
/// TODO:Using promises
// var promise_importer = cloudsponge.authorize("gmail", AUTHENTICATION);
// promise_importer.done(function(contact_obj){
// var collection = contact_obj.getContacts();
// });