readMessageFolders

The readMessageFolders function attempts to return message folders that match all of the given filter. The specified attributes of the folders are returned for each matching folder.

Results

The readMessageFolders function may return 1 or many message folder objects. See the documentation on the messageFolderObject for a list of the data fields that could potentially be returned.

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

Syntax

messageFolderObject[] folders = bApi.readMessageFolders(filter messageFolderFilter, pageNumber);

Parameters

Name Type Required Description
filter messageFolderFilter Yes Used to filter which message object is returned.
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
/**
 * This example will read the message folders from your account and print
 * them out in 'tree-like' fashion.
 */
 
$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));
 
  // get all folders
  $filter = array();
 
  print "reading message folders\n";
  $folders = $client->readMessageFolders(array('pageNumber' => 1,
                         'filter' => $filter,
                         )
                       )->return;
 
  // find the root first
  $rootFolder = null;
  foreach($folders as $folder) {
    if (!$folder->parentId) {
      $rootFolder = $folder;
      break;
    }
  }
 
  // start building up a visual tree view of the folders
  $folderStack = array(array('folder' => $rootFolder,
                 'depth' => 0));
 
  $output = "";
  while (count($folderStack) > 0) {
    $item = array_pop($folderStack);
    $currentFolder = $item['folder'];
    $depth = $item['depth'];
    $indent = str_repeat("    ", $depth);
    $output .= $indent . $currentFolder->name . "\n";
    foreach ($folders as $folder) {
      if ($folder->parentId == $currentFolder->id) {
        array_push($folderStack, array('folder' => $folder, 'depth' => $depth + 1));
      }
    }
  }
 
  // print out the tree
  print $output . "\n";
 
} catch (Exception $e) {
  print "uncaught exception\n";
  print_r($e);
}