Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getActiveSubscribers example #3

Open
abigwonderful opened this issue Jul 8, 2014 · 1 comment
Open

getActiveSubscribers example #3

abigwonderful opened this issue Jul 8, 2014 · 1 comment

Comments

@abigwonderful
Copy link

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]);
        }
    }
  );
@jeremypeter
Copy link

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);
            });

          }
        });
      });
    }
  });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants