Created
February 27, 2014 13:28
-
-
Save codingisacopingstrategy/9249967 to your computer and use it in GitHub Desktop.
Interacting with the Funambol API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* So I logged, opened up the console, and this worked. | |
* | |
* I did add jQuery with the jQuerify extension though | |
* Underscore is already loaded. | |
* | |
*/ | |
var contacts; | |
$.ajax({ | |
url: '/sapi/contact?action=get', | |
type: 'POST', | |
contentType: 'application/json', | |
data: data, | |
dataType: 'json', | |
processData: false, | |
}).done(function(data) { | |
console.log(data); | |
contacts = data; | |
}); | |
/* Or, on the serverside, once we’ve outputted it into json: | |
var fs = require('fs'); | |
var _ = require('underscore'); | |
var contacts = JSON.parse(fs.readFileSync('contacts.json')); | |
*/ | |
var emails = _.flatten(_.map( _.compact( | |
_.pluck(contacts, "email") | |
), function(mailobjects) { | |
return _.pluck(mailobjects, "v"); | |
}) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment