Bronto Email: Use Bronto API to List Contact Fields in PHP

12/15/2014 8:38:50 PM

Bronto is an email marketing campaign service. The following code will allow you to call the Bronto API to list fields associated with your contacts.

<?php

$bronto_api_key = "YOUR SPECIAL KEY";

$bronto_api = new SoapClient('https://api.bronto.com/v4?wsdl', array('trace' => 1, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS));

// Create an API session
$bronto_session_id = $bronto_api->login(array('apiToken' => $bronto_api_key))->return;
$bronto_session_header = new SoapHeader("http://api.bronto.com/v4", 'sessionHeader', array('sessionId' => $bronto_session_id));
$bronto_api->__setSoapHeaders(array($bronto_session_header));
	
	
// filter on fields that contain 'name'
$filter = array('name' => array('operator' => 'Contains',
								'value' => 'origin',
								),
				);

//OR
//apply no filter
$filter = array();
		  
$fields = $bronto_api->readFields(array('pageNumber' => 1,
										'filter' => $filter,
										)
								)->return;
   
// print matching results
foreach ($fields as $field)
{
	print "<div>Field name: " . $field->name . "; type: " . $field->type . "</div>";
}