readDeliveries

The readDeliveries function attempts to return deliveries that match all of the given filter. A delivery is a message that has been sent to a specific set of recipients. Although a delivery is associated with a message, the message’s content may have changed since the delivery was performed and so should not be used for determining the actual content sent. Instead, the content that was delivered may be included in the return of this function.

Results

The readDeliveries function may return 1 or many delivery objects. See the documentation on the deliveryObject 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

deliveryObject[] deliveries = bApi.readDeliveries( filter deliveryFilter
	      includeRecipients, includeContent, pageNumber, includeOrderIds, includeCampaignId);

Parameters

Name Type Required Description
filter deliveryFilter Yes A filter used for returning specific deliveries.
includeRecipients boolean Yes Include the recipients of returned deliveries. You will get back an array of the recipients who were, or are scheduled to receive the delivery. If the delivery was sent to a list, you will get back a list ID. If it was sent to a segment, you will get back a segment ID. If it was sent to an individual contact, you will get back a contact ID. If the delivery was sent to a combination of items (lists, segments, and contacts), you will get back an id for each item.
includeContent boolean Yes Include the content of returned deliveries.
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.
includeOrderIds boolean No Include the order IDs associated with returned deliveries. You will get back an array of IDs for orders associated with the delivery. This only returns orderIDs that triggered the delivery; it does not return the Order ID/Cart ID associated with a delivery from a conversion.
includeCampaignId boolean No Include the campaignID with returned deliveries. The parameter should be set to true to return the campaignID.

PHP Code Example

<?php
/**
 * This example will read the details of any delivery made in your Bronto
 * account in the last 24 hours, and print out what message was sent, to how
 * many contacts, how many messages were actually delivered, and how many of
 * those contacts opened or clicked on links in your message.
 */
 
$client = new SoapClient('https://api.bronto.com/v4?wsdl', array('trace' => 1, 
                                 'features' => SOAP_SINGLE_ELEMENT_ARRAYS));
setlocale(LC_ALL, 'en_US');
 
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));
 
  // compute date/time 24 hours ago
  $startDate = date('c', time() - (2* 24 * 60 * 60)); // 24 hours * 60 minutes * 60 seconds;
 
  // set up a filter to read deliveries in the last 24 hours
  $filter = array('start' => array('operator' => 'After',
                   'value' => $startDate,
                   ),
          'status' => 'sent',
          );
 
  print "reading deliveries completed from past 24 hours\n";
  $deliveries = $client->readDeliveries(array('pageNumber' => 1,
                        'includeRecipients' => false,
                        'includeCampaignId' => false,
                        'includeContent' => false,
                        'filter' => $filter,
                        )
                      )->return;
 
  // print matching results
  foreach ($deliveries as $delivery) {
    // get name of the message sent.
    $msgFilter = array('id' => $delivery->messageId);
    $message = array_pop($client->readMessages(array('pageNumber' => 1,
                             'includeContent' => false,
                             'filter' => $msgFilter))->return);
    $startString = strftime('%c', strtotime($delivery->start));
    print "Message: \"" . $message->name . "\" sent at: " . $startString . "\n";
    print "\tSent: " . $delivery->numSends . "\n\tDelivered: " . $delivery->numDeliveries . " (" .
      number_format((($delivery->numDeliveries / $delivery->numSends) * 100), 0, '.', ',') . "%)\n";
    print "\tOpens: " . $delivery->numOpens . "\n\tClicks: " . $delivery->numClicks . "\n";
  }
 
} catch (Exception $e) {
  print "uncaught exception\n";
  print_r($e);
}

Python Code Example

from suds.client import Client
from suds import WebFault
import sys
import logging
 
 
# Tested with Python 2.6.1 and suds soap library version 0.4
 
# See suds home page:
# https://fedorahosted.org/suds/
 
 
 
# Bronto API WSDL
BRONTO_WSDL = 'https://api.bronto.com/v4?wsdl'
 
# start up basic logging
logging.basicConfig()
 
TOKEN = "ADD TOKEN HERE"
 
 
# login using the token to obtain a session ID
bApi = Client( BRONTO_WSDL )
 
try:
    session_id = bApi.service.login(TOKEN)
# just exit if something goes wrong
except WebFault, e:
   print '\nERROR MESSAGE:'
   print e
   sys.exit()
 
# Set up the soap headers using the
# session_id obtained from login()
session_header = bApi.factory.create("sessionHeader")
session_header.sessionId = session_id
bApi.set_options(soapheaders=session_header)
 
# Set up a deliveryFilter that will return deliveries
# made in the specified date range
filter = bApi.factory.create('deliveryFilter')
start = bApi.factory.create('dateValue')
start.operator = "After"
start.value = "2013-05-09T19:20:30-05:00"
 
end = bApi.factory.create('dateValue')
end.operator = "Before"
end.value = "2013-06-12T19:20:30-05:00"
 
filter.type = 'AND'
filter.start = [start, end]
 
 
pageNumber = 1
 
try:
    read_deliveries = bApi.service.readDeliveries(filter, includeRecipients = True, includeContent = False, includeCampaignId = True, pageNumber = 1)
except WebFault, e:
    print '\nERROR MESSAGE:'
    print e
    sys.exit()
print read_deliveries