如何显示来自 mail chimp API 版本 3 的电子邮件 ID 列表?

How do I display list of email id From mail chimp API version 3?

我已经使用电子邮件订阅更新特定列表 ID,现在我想提取所有电子邮件 ID 并想检查该特定电子邮件 ID 是否已经存在并显示消息 "email is already exist" 如果不存在然后将该电子邮件 ID 插入邮件黑猩猩。

function mailchimp_subscriber_status( $email, $status, $list_id, $api_key, $merge_fields = array('FNAME' => '','LNAME' => '') ){
    $data = array(
        'apikey'        => $api_key,
            'email_address' => $email,
        'status'        => $status,
        'merge_fields'  => $merge_fields
    );

    $mch_api = curl_init(); // initialize cURL connection

    curl_setopt($mch_api, CURLOPT_URL, 'https://' . substr($api_key,strpos($api_key,'-')+1) . '.api.mailchimp.com/3.0/lists/' . $list_id . '/members/' . md5(strtolower($data['email_address'])));
    //curl_setopt($mch_api, CURLOPT_USERPWD, 'user:' . $api_key);
    //curl_setopt($mch_api, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
    curl_setopt($mch_api, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Basic '.base64_encode( 'user:'.$api_key )));
    curl_setopt($mch_api, CURLOPT_USERAGENT, 'PHP-MCAPI/2.0');
    curl_setopt($mch_api, CURLOPT_RETURNTRANSFER, true); // return the API response
    curl_setopt($mch_api, CURLOPT_CUSTOMREQUEST, 'PUT'); // method PUT
    curl_setopt($mch_api, CURLOPT_TIMEOUT, 10);
    curl_setopt($mch_api, CURLOPT_POST, true);
    curl_setopt($mch_api, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($mch_api, CURLOPT_POSTFIELDS, json_encode($data) ); // send data in json

    $result = curl_exec($mch_api);
    $httpCode=curl_getinfo($mch_api, CURLINFO_HTTP_CODE);
    //var_dump($httpCode); die;
    //$json = json_decode($result);
    //echo $json->{'status'}; die;
    //var_dump($result); die;
    return $result;
}
<?php
require_once 'inc/MCAPI.class.php';
$api = new MCAPI('[[YOUR_API_KEY]]');
$merge_vars = array('FNAME'=>$_POST["fname"], 'LNAME'=>$_POST["lname"]);


$retval = $api->listSubscribe( '[[YOUR_LIST_ID]]', $_POST["email"], $merge_vars, 'html', false, true );

if ($api->errorCode == 214){
echo "<h4>You are already subscribed.</h4>";
} else {
echo "<h4>Thank you, you have been added to our mailing list.</h4>";
}
?>
function mailchimp_subscriber_status( $email, $status, $list_id, $api_key, $merge_fields = array('FNAME' => '','LNAME' => '') ){
    $data = array(
        'apikey'        => $api_key,
            'email_address' => $email,
        'status'        => $status,
        'merge_fields'  => $merge_fields
    );

    $mch_api = curl_init(); // initialize cURL connection

    curl_setopt($mch_api, CURLOPT_URL, 'https://' . substr($api_key,strpos($api_key,'-')+1) . '.api.mailchimp.com/3.0/lists/' . $list_id . '/members/' . md5(strtolower($data['email_address'])));
    //curl_setopt($mch_api, CURLOPT_USERPWD, 'user:' . $api_key);
    //curl_setopt($mch_api, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
    curl_setopt($mch_api, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Basic '.base64_encode( 'user:'.$api_key )));
    curl_setopt($mch_api, CURLOPT_USERAGENT, 'PHP-MCAPI/2.0');
    curl_setopt($mch_api, CURLOPT_RETURNTRANSFER, true); // return the API response
    curl_setopt($mch_api, CURLOPT_CUSTOMREQUEST, 'PUT'); // method PUT
    curl_setopt($mch_api, CURLOPT_TIMEOUT, 10);
    curl_setopt($mch_api, CURLOPT_POST, true);
    curl_setopt($mch_api, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($mch_api, CURLOPT_POSTFIELDS, json_encode($data) ); // send data in json

    $result = curl_exec($mch_api);
    $httpCode=curl_getinfo($mch_api, CURLINFO_HTTP_CODE);
    //var_dump($httpCode); die;
    //$json = json_decode($result);
    //echo $json->{'status'}; die;
    //var_dump($result); die;
    return $result;
}

我这样做并添加了订阅者,但现在我想检索订阅者列表,我没有使用邮件黑猩猩 class。

$httpCode=curl_getinfo($mch_api, CURLINFO_HTTP_CODE);  
if ($httpCode == 200) {
            $_SESSION['msg'] = '<p style="color: #34A853">You have successfully subscribed to CodexWorld.</p>';
        } else {
            switch ($httpCode) {
                case 214:
                    $msg = 'You are already subscribed.';
                    break;
                default:
                    $msg = 'Some problem occurred, please try again.';
                    break;
            }
            $_SESSION['msg'] = '<p style="color: #EA4335">'.$msg.'</p>';
        }
    }else{
        $_SESSION['msg'] = '<p style="color: #EA4335">Please enter valid email address.</p>';
    }