Back to Documentation OverviewlistBatchUnsubscribe
public static listBatchUnsubscribe(string uid, string id, array emails, boolean delete_member, boolean send_goodbye, boolean send_notify)
Unsubscribe a batch of email addresses to a list
- Section:
- List Related
- Parameters:
| uid | the id for your user account. Get by calling login($user, $pass) |
| id | the list id to connect to |
| emails | array of email addresses to unsubscribe |
| delete_member | flag to completely delete the member from your list instead of just unsubscribing, default to false |
| send_goodbye | flag to send the goodbye email to the email addresses, defaults to true |
| send_notify | flag to send the unsubscribe notification email to the address defined in the list email notification settings, defaults to false |
- Returns:
- struct - Array of result counts and any errors that occurred
- Returned Fields:
| integer | success_count | Number of email addresses that were succesfully added/updated |
| integer | error_count | Number of email addresses that failed during addition/updating |
| array | errors | Array of error structs. Each error struct will contain "code", "message", and "email" |
Examples (1)[1] mcapi_listBatchUnsubscribe.php<?php /** This Example shows how to run a Batch Unsubscribe on a List using the MCAPI.php class and do some basic error checking or handle the return values. **/ // Include the MailChimp API code. Do Not Edit This! include('inc/MCAPI.class.php'); include('config.inc'); //username & pass // Connect to the MailChimp server with the user's credentials. $api = new MCAPI($mailChimpUser, $mailChimpPass); $emails = array('INVALID01@mailchimp.com','INVALID02@mailchimp.com'); $delete = false; //don't completely remove the emails $bye = true; // yes, send a goodbye email $notify = false; // no, don't tell me I did this $vals = $api->listBatchUnsubscribe($id, $emails, $delete, $bye, $notify); if (!$vals){ // an api error occurred echo "code:".$api->errorCode."\n"; echo "msg :".$api->errorMessage."\n"; } else { echo "success:".$vals['success_count']."\n"; echo "errors:".$vals['error_count']."\n"; foreach($vals['errors'] as $val){ echo $val['email_address']. " failed\n"; echo "code:".$val['code']."\n"; echo "msg :".$val['message']."\n"; } } ?>
|