Skip to content

Instantly share code, notes, and snippets.

@codingisacopingstrategy
Created February 27, 2014 13:28
Show Gist options
  • Save codingisacopingstrategy/9249967 to your computer and use it in GitHub Desktop.
Save codingisacopingstrategy/9249967 to your computer and use it in GitHub Desktop.
Interacting with the Funambol API
/* 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