readSegments

The readSegments function attempts to return segments that match all of the given filter. The specified attributes of the segments are returned for each matching segment.

Results

The readSegments function may return 1 or many segment objects. See the documentation on the segmentObject 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

segmentObject[] segments = bApi.readSegments( filter segmentFilter, pageNumber);

readSegment Parameters

Name Type Required Description
filter segmentFilter Yes Used to filter which segment 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.
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.

PHP Code Example

<?php
/**
 * This example will read all segments from your account that contain 
 * the word 'test' as a part of their name.  It will then print out
 * the name of the segment and its id.
 */
 
$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 segments that contain the word 'test'
  $filter = array('name' => array('operator' => 'Contains',
                  'value' => 'test'
                  )
          );
 
  print "reading segments\n";
  $segments = $client->readSegments(array('pageNumber' => 1,
                      'filter' => $filter,
                      )
                    )->return;
 
  // print matching results
  foreach ($segments as $segment) {
    print "Segment name: " . $segment->name . "; id: " . $segment->id . "\n";
  }
 
} catch (Exception $e) {
  print "uncaught exception\n";
  print_r($e);
}