readContactswithlatestunsubscribedate

The readContactsWithLatestUnsubscribeDate function attempts to return contacts that match all of the given filters. If the contact has unsubscribed, then lastUnsubscribeDate is also returned.

Results

The readContactsWithLatestUnsubscribeDate function may return 1 or many contact objects. See the documentation on the contactObject for a list of the data fields that could potentially be returned. For more information on result limits and paging, see How To Read Objects.

Note: The data fields returned depend on the type of data you ask for in your request.

Syntax

contactObject[] contacts = bApi.readContactsWithLatestUnsubscribeDate( filter contactFilter, 
	      includeLists, fields, pageNumber, includeSMSKeywords, includeGeoIPData, 
	      includeTechnologyData, includeRFMData);

Parameters

Name Type Required Description
filter contactFilter Yes The filter used to return a specific contact.
includeLists boolean No The lists, referenced by id, that the contact belongs to.
fields string, array No The fields you want returned that the contact belongs to. Fields are referenced by their unique id. You can pass in a single id as a string, or multiple ids in an array.
pageNumber int Yes Retrieves the next “batch” of objects as the value specified increases from 1. In order to obtain an entire set of objects for a given call, you should increase the number value assigned to pageNumber until no more objects are returned.
includeSMSKeywords boolean No The SMS keywords the contact is subscribed to.
includeGeoIPData boolean No Includes the following data in the readOnlyContactData object:
  • geoIPCity
  • geoIPStateRegion
  • geoIPZip
  • geoIPCountry
  • geoIPCountryCode
includeTechnologyData boolean No Includes the following data in the readOnlyContactData object:
  • primaryBrowser
  • mobileBrowser
  • primaryEmailClient
  • mobileEmailClient
  • operatingSystem
includeRFMData boolean No Includes the following data in the readOnlyContactData object:
  • firstOrderDate
  • lastOrderDate
  • lastOrderTotal
  • totalOrders
  • totalRevenue
  • averageOrderValue
includeEngagementData boolean No Includes the following data in the readOnlyContactData object:
  • lastDeliveryDate
  • lastOpenDate
  • lastClickDate
customSource string No A user-defined source used to indicate where the contact came from.

Example Response

stdClass Object
(
    [id] => be4214ab43d9-b782-38b47d23033b
    [email] => test@example.com
    [status] => unsub

    [msgPref] => html
    [source] => import
    [customSource] => birthday campaign
    [created] => 2016-11-29T09:36:24-05:00
    [modified] => 2017-10-05T16:58:36-04:00
    [deleted] =>
    [numSends] => 0
    [numBounces] => 0
    [numOpens] => 0
    [numClicks] => 0
    [numConversions] => 0
    [conversionAmount] => 0
    [lastUnsubscribeDate] => 2016-11-29T16:44:07Z
)

PHP Code Example

<?php 
/** This example will log into your account and try to read the 
 * contacts 'john.doe@example.com' and 'jane.doe@example.com' 
 * in two ways: first, by specifically matching on those email 
 * addresses, and then second by matching on any contact whose 
 * email address contains 'doe@example.com'.
 *  It also prints the * matched contacts' status. */

 $client = new SoapClient('https://api.bronto.com/v4?wsdl', array('trace' => 1, 
                                 'features' => SOAP_SINGLE_ELEMENT_ARRAYS));
 
try {
  $token = "YOUR_TOKEN_HERE";
 
  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));
 
  // set up a filter to read contacts and match on either of two email addresses
  $filter = array('type' => 'OR',
          'email' => array(array('operator' => 'EqualTo',
                       'value' => 'john.doe@example.com'
                       ),
                   array('operator' => 'EqualTo',
                       'value' => 'jane.doe@example.com'
                       )
                   ),
          ); 
 
  print "reading contacts with equalto filter\n";
  $contacts = $client->readContactsWithLatestUnsubscribeDate(array('pageNumber' => 1,
                      'includeLists' => false,
                      'filter' => $filter,
                      )
                    )->return;
 
  // print matching contact email addresses
  foreach ($contacts as $contact) {
    print $contact->email . ': ' . $contact->status . "\n";
  }
 
 
  // set up a filter to read contacts and match on either of two email addresses
  $filter = array('email' => array(array('operator' => 'Contains',
                       'value' => 'doe@example.com'
                       ),
                   ),
          ); 
 
  print "reading contacts with contains filter\n";
  $contacts = $client->readContacts(array('pageNumber' => 1,
                      'includeLists' => false,
                      'filter' => $filter,
                      )
                    )->return;
 
  // print matching contact email addresses
  foreach ($contacts as $contact) {
    print $contact->email . ': ' . $contact->status . "\n";
  }
 
} catch (Exception $e) {
  print "uncaught exception\n";
  print_r($e);
}