readUnsubscribes
Returns delivery data, or each unsubscribe for all contacts in an account.
Results
The readUnsubscribes
function may return one or many unsubscribe objects.
See the documentation for unsubscribeObject
to view the data that could
potentially be returned.
Syntax
unsubscribeObject[] unsubscribes = bApi.readUnsubscribes(filter unsubscribeFilter, pageNumber);
Parameters
Name | Type | Required | Comments |
---|---|---|---|
filter |
unsubscribeFilter | Yes | The filter used to return specific unsubscribe data. |
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. |
PHP Code Example
<?php /** * Returns each unsubscribe for all contacts in an account. * You can filter what unsubscribes are returned using the unsubscribeFilter * @see ../reference/r_api_soap_unsubscribefilter/ * * @param int $pageNumber * Returns the next batch of objects as you increase the value from 1 * @param unsubscribeFilter $filter * The filter used to return specific unbsubscribe data * * @return array An array containing unsubscribe objects * @see ../reference/r_api_soap_general_unsubscribeobject/ * * @copyright Copyright (c) 2018 Oracle + Bronto */ $client = new SoapClient('https://api.bronto.com/v4?wsdl', array('trace' => 1, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS)); try { $token = "YOUR_API_KEY"; 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)); // No filter set $filter = array(); // Example filter by ContactId //$filter = array("contactId" => "CONTACT_ID"); print "reading all lists\n"; $unsubscribes = $client->readUnsubscribes(array('pageNumber' => 1,'filter' => $filter))->return; print_r($unsubscribes); foreach ($unsubscribes as $unsubscribe) { // Print contactId, method, and date unsubscribed print "contactId: " . $unsubscribe->contactId . "; method: " . $unsubscribe->method . "; created: " . $unsubscribe->created . "\n"; } } catch (Exception $e) { print "uncaught exception\n"; print_r($e); } ?>