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
Cool , then you can check like..
if( $result['name'] === 'List_AlreadySubscribed' ) {
return $result['error'];// which returns "[email protected] is already subscribed to list SyncTest. Click here to update your profile." as a string.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With