Back to Documentation Overview

listBatchUnsubscribe

public static listBatchUnsubscribe(string apikey, 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:
apikey a valid API Key for your user account. Get by calling login()
id the list id to connect to. Get by calling lists()
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)

download example code

[1] mcapi_listBatchUnsubscribe.php

  1. <?php
  2. /**
  3. This Example shows how to run a Batch Unsubscribe on a List using the MCAPI.php
  4. class and do some basic error checking or handle the return values.
  5. **/
  6. require_once 'inc/MCAPI.class.php';
  7. require_once 'inc/config.inc.php'; //contains apikey
  8.  
  9. $api = new MCAPI($apikey);
  10.  
  11. $emails = array($my_email, $boss_man_email);
  12. $delete = false; //don't completely remove the emails
  13. $bye = true; // yes, send a goodbye email
  14. $notify = false; // no, don't tell me I did this
  15.  
  16. $vals = $api->listBatchUnsubscribe($listId, $emails, $delete, $bye, $notify);
  17.  
  18. if ($api->errorCode){
  19. // an api error occurred
  20. echo "code:".$api->errorCode."\n";
  21. echo "msg :".$api->errorMessage."\n";
  22. } else {
  23. echo "success:".$vals['success_count']."\n";
  24. echo "errors:".$vals['error_count']."\n";
  25. foreach($vals['errors'] as $val){
  26. echo "\t*".$val['email']. " failed\n";
  27. echo "\tcode:".$val['code']."\n";
  28. echo "\tmsg :".$val['message']."\n\n";
  29. }
  30. }
  31. ?>
  32.  
  33.  
  34.  
Add New Note User Contributed Notes for listBatchUnsubscribe
No notes, yet... Will you be the first??