MailChimp API 2.0 Error Response for existing E-Mail Address

Viewed 3875

I am trying to get a response from MailChimp to return a message to the Subscriber. The subscribtion is working fine but I do not get any response from MailChimp. I am a Noob at PHP so do I neeed to use JSON or can it be done like in my Code with PHP?

$MailChimp = new \drewm\MailChimp('12122338484487841-us1');
$result = $MailChimp->call('lists/subscribe', array(
        'id'                => '1123334444',
        'email'             => array('email'=>$check_mail['customers_email_address']),
        'merge_vars'        => array('FNAME'=>$check_mail['customers_firstname'], 'LNAME'=>$check_mail['customers_lastname']),
        'double_optin'      => true,
        'update_existing'   => false,
        'replace_interests' => false,
        'send_welcome'      => true,
));     

// CHECK MAILCHIMP IF EMAIL EXIST
if( $result === false ) {
    return 'You have already subscribed to the List';
}
else if( isset($result->status) && $result->status == 'error' ) {
    // Error info: $result->status, $result->code, $result->name, $result->error
}
// CHECK MAILCHIMP IF EMAIL EXIST           

Thanks

1 Answers
Related