readMessages

The readMessagesfunction attempts to return messages that match the given filter. Currently the API does not support the structure of email message editor messages. While you can attempt to read this type of message, the content structure may be incomprehensible.

Results

The readMessages function may return 1 or many message objects. See the documentation for messageObject and 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

messageObject[] messages = bApi.readMessages(filter messageFilter, includeContent, pageNumber, pageSize, includeTransactionalApproval);

readMessages Parameters

Name Type Required Description
filter messageFilter Yes A filter used for returning specific messages.
includeContent boolean Yes Returns an array of the message content {type, subject, content}
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.
pageSize int No Allows you to set a limit for the page size in order to improve performance speed. If set, the pageSize minimum is 10 and the maximum is 5,000.
includeTransactionalApproval boolean No Returns the transactional approval status of a message. Values returned include accepted, unapproved, and requested.

PHP Code Example

<?php
/**
 * This example will match messages in your account that contain the word 'newsletter'
 * in their name.  It will then print out the message names and ids.
 */
 
$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));
 
  $filter = array('name' => array('operator' => 'Contains',
                  'value' => 'newsletter')
          );
 
  print "reading all matching messages\n";
  $messages = $client->readMessages(array('pageNumber' => 1,
                      'includeContent' => false,
                      'filter' => $filter))->return;
 
  // print matching message names and ids
  foreach ($messages as $message) {
    print "Name: " . $message->name . "; id: " . $message->id . "\n";
  }
 
} catch (Exception $e) {
  print "uncaught exception\n";
  print_r($e);
}