« Back to Documentation Overview

listMembers – v1.3

 listMembers(string apikey, string id, string status, string since, int start, int limit)

Get all of the list members for a list that are of a particular status. Are you trying to get a dump including lots of merge data or specific members of a list? If so, checkout the Export API

Section
List Related
mcapi_listMembers.php
Parameters
apikey a valid API Key for your user account. Get by visiting your API dashboard
id the list id to connect to. Get by calling lists()
status the status to get members for - one of(subscribed, unsubscribed, cleaned, updated), defaults to subscribed
since optional - pull all members whose status (subscribed/unsubscribed/cleaned) has changed or whose profile (updated) has changed since this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr)
start optional - for large data sets, the page number to start at - defaults to 1st page of data (page 0)
limit optional - for large data sets, the number of results to return - defaults to 100, upper limit set at 15000
Returns
array Array of a the total records match and matching list member data for this page (see Returned Fields for details)
inttotalthe total matching records
arraydatathe data for each member, including:
stringemailMember email address
date timestamp timestamp of their associated status date (subscribed, unsubscribed, cleaned, or updated) in GMT
stringreasonFor unsubscribes only - the reason collected for the unsubscribe. If populated, one of 'NORMAL','NOSIGNUP','INAPPROPRIATE','SPAM','OTHER'
stringreason_textFor unsubscribes only - if the reason is OTHER, the text entered.

Examples (1)

download example code

[1] mcapi_listMembers.php

  1. <?php
  2. /**
  3. This Example shows how to pull the Members of a List using the MCAPI.php
  4. class and do some basic error checking.
  5. **/
  6. require_once 'inc/MCAPI.class.php';
  7. require_once 'inc/config.inc.php'; //contains apikey
  8.  
  9. $api = new MCAPI($apikey);
  10.  
  11. $retval = $api->listMembers($listId, 'subscribed', null, 0, 5000 );
  12.  
  13. if ($api->errorCode){
  14. echo "Unable to load listMembers()!";
  15. echo "\n\tCode=".$api->errorCode;
  16. echo "\n\tMsg=".$api->errorMessage."\n";
  17. } else {
  18. echo "Members matched: ". $retval['total']. "\n";
  19. echo "Members returned: ". sizeof($retval['data']). "\n";
  20. foreach($retval['data'] as $member){
  21. echo $member['email']." - ".$member['timestamp']."\n";
  22. }
  23. }
  24.  
  25. ?>
  26.