createsend-node
createsend-node copied to clipboard
getActiveSubscribers example
rather than harassing you for full documentation, I was wondering if you could share a little insight on how to use getActiveSubscribers? I'm very new to both node and campaign monitor and struggling a bit.
what I've got:
//more module dependancies above
var createsend = require('createsend-node'),
auth = { apiKey: 'XXXXXXXX' },
api = new createsend(auth);
//unsub is my mongo schema
unsub.statics.CMCall = function(callback){
//where do i provide the listid???
api.list.getActiveSubscribers(
function (err, subscribers){
for( var i = 0; i < subscribers.length; subscribers++){
console.log(subscribers[i]);
}
}
);
Here's a quick example of how could do this
api.account.getClients(function(err, clients){
clients.forEach(function(client){
if(client.name === 'Client Name'){
var clientId = client.clientId;
api.clients.getLists(clientId, function(err, lists){
lists.forEach(function(list){
if(list.Name === "List Name"){
var listId = list.ListID;
// Filter how results are returned
// https://www.campaignmonitor.com/api/lists/#active_subscribers
// ex. { orderField: 'name' }
var filter = {};
api.lists.getActiveSubscribers(listId, filter, function(err, results){
// Mess with results here
console.log(results);
});
}
});
});
}
});
});