removeFromList

The removeFromList function allows you to remove one or more contacts from a list. This does not delete the contact from your account.

Syntax

writeResult = bApi.removeFromList(mailListObject lists, contactObject[] contacts);

List Object Attributes

Name Type Required Description
id string Yes (unless the list name is used) The unique id assigned to the list. You can obtain the id for a list by calling readLists, or by looking at the footer when viewing the overview page for an individual list in the application.
name string Yes (unless name the list id is used) The internal name of the list.

Contact Object Attributes

Name Type Required Description
id string Yes (unless name the contact email is used) The unique id assigned to the contact. You can obtain the id for a contact by calling readContacts, or by looking at the footer when viewing the overview page for an individual contact in the application.
email string Yes (unless name the contact id is used) The email address assigned to the contact. The email address can be used to reference a specific contact when using the contact functions.

PHP Code Example

      <?php
        /**
        * This script will incrementally remove a contact from a list. The contact will only
        * be removed from one list.
        *
        * @copyright Copyright (c) 2018 Oracle + Bronto Software (http://www.bronto.com)
        */
 
      $client = new SoapClient('https://api.bronto.com/v4?wsdl', array('trace' => 1,
                                       'features' => SOAP_SINGLE_ELEMENT_ARRAYS));
      try {
        // Add your API token
          $token = "ADD YOUR API TOKEN";
 
          print "Logging in\n";
          $sessionId = $client->login(array('apiToken' => $token))->return;
 
          $session_header = new SoapHeader(
              "http://api.bronto.com/v4",
              'sessionHeader',
              array('sessionId' => $sessionId)
          );
          $client->__setSoapHeaders(array($session_header));
 
          /**
           * $mailListObject is an array containing the list information.
           * You can pass the list id and/or the list name.
           * The list id is the unique id assigned to the list. You can obtain
           * the id for a list by calling readLists, or by looking at the footer
           * when viewing the overview page for an individual list in the application.
           * The list name is the internal name for your list. We recommend
           * using the list id instead of the list name to speed up your API calls.
          */
 
        // Example with both id and name included.
          $mailListObject = array("id" => "LIST ID",
                        "name" => "LIST NAME");
 
        // Example with only list id.
        //$mailListObject = array("id" => "LIST ID");
 
        // Example with only internal name.
        //$mailListObject = array("name" => "LIST NAME");
 
      /** $contactObject is an array containing the contact information.
        * The contact API id is a unique identifier assigned to a contact.
        * You can find the contact API id for a contact by looking at the footer when
        * viewing the overview page for an individual contact in the application.
        * The contact email address can also be used as an id when adding contact(s).
        */
 
        // Example using both id and email.
          $contactObject = array("id" => "CONTACT ID",
                    "email" => "CONTACT EMAIL ADDRESS");
 
       // Example with id only.
       //$contactObject = array("id" => "CONTACT ID");
 
       // Example with email only.
       //$contactObject = array("email" => "CONTACT EMAIL ADDRESS");
 
       // Example with multiple contacts.
       // $contact1 = array("email" => "FIRST CONTACT EMAIL");
       // $contact2 = array("email" => "SECOND CONTACT EMAIL");
       // $contact3 = array("email" => "THIRD CONTACT EMAIL");
       // $contactObject = array($contact1, $contact2, $contact3);
 
 
          $write_result = $client->removeFromList(array('list' => $mailListObject, 'contacts' => $contactObject))->return;
 
          if ($write_result->results[0]->isError) {
              print "There was a problem removing the contact from the list.\n";
          } else {
              print "The contact has been removed.  Id: " . $write_result->results[0]->id . "\n";
          }
      } catch (Exception $e) {
         print "uncaught exception\n";
         print_r($e);
       }
      ?>