How can I pull a subscriber account from a MailChimp list using the API?

I am trying to display the subscriber’s account from the MailChimp mailing list using their API, and I partially work with it, except that the code below is currently calculating the number of subscribers for all lists, and not for one specific list. I specified the list identifier in the line $ listId = 'XXX'; but this does not seem to work. Since I have only five lists, the output from PHP below shows this:

10 0 0 1 9

What do I need to do in my code below to count the number of subscribers from a specific list id?

<?php
/**
This Example shows how to pull the Members of a List using the MCAPI.php 
class and do some basic error checking.
**/
require_once 'inc/MCAPI.class.php';

$apikey = 'XXX';
$listId = 'XXX';

$api = new MCAPI($apikey);

$retval = $api->lists();

if ($api->errorCode){
    echo "Unable to load lists()!";
    echo "\n\tCode=".$api->errorCode;
    echo "\n\tMsg=".$api->errorMessage."\n";
} else {
    foreach ($retval['data'] as $list){
        echo "\t ".$list['stats']['member_count'];
    }
}

?>

(. ), , list_id. , , list_id .

, ? $params [ "filters" ] = $filters;

MailChimp () : http://apidocs.mailchimp.com/rtfm/lists.func.php

    function lists($filters=array (
), $start=0, $limit=25) {
        $params = array();
        $params["filters"] = $filters;
        $params["start"] = $start;
        $params["limit"] = $limit;
        return $this->callServer("lists", $params);
    }
+3
2

, , - , . , , , .

Anywho, , :

$filters = array('list_id'=>'XXXX');
$lists = $api->lists($filters);
+2

Mailchimp - api http://apidocs.mailchimp.com/downloads/#php. api (), , , :

int member_count .

, , . , , , , , . .

+1

All Articles