readMessageRules

The readMessageRules function attempts to return Automated Message Rules that match all of the given filter. The specified attributes of the rules are returned for each matching rule.

Results

The readMessageRules function may return 1 or many message rule objects. See the documentation on the messageRuleObject 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

messageRuleObject[] messageRules = bApi.readMessageRules(filter messageRuleFilter, pageNumber);

Parameters

Name Type Required Description
filter messageRuleFilter Yes Used to filter which Automated Message Rule objects are 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 automated message rules from your account
 * that are 'recurring' (i.e. happen on a recurring date).  The matching
 * automated message rules will print out their names and ids.
 */
 
$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 rules
  $filter = array();
 
  print "reading automated message rules\n";
  $rules = $client->readMessageRules(array('pageNumber' => 1,
                       'filter' => $filter,
                       )
                     )->return;
 
  // print matching results
  foreach ($rules as $rule) {
    if ($rule->type == 'recurring') {
      print "Rule name: " . $rule->name . "; id: " . $rule->id . "\n";
    }
  }
 
} catch (Exception $e) {
  print "uncaught exception\n";
  print_r($e);
}