readWebforms

The readWebforms function attempts to return webforms that match all of the given filters.

Results

The readWebforms function may return 1 or many webform objects. See the documentation on the webformObject for a list of the data fields that could potentially be returned.

Syntax

webformObject[] webforms = bApi.readWebforms( filter webformFilter, pageNumber);

Parameters

Name Type Required Description
filter webformFilter Yes The filter used to return specific webforms.
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 return webform objects for webforms
 * that whose name matched the given filter.
 */
 
$client = new SoapClient('https://api.bronto.com/v4?wsdl', 
                          array('trace' => 1,
                                'features' => SOAP_SINGLE_ELEMENT_ARRAYS)
                        );
 
try {
 
    // Add in a valid API token
    $token = "ADD 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));
    // set up a filter to read webforms
    $filter = array('type' => 'AND',
                'name' => array('operator' => 'Contains',
                                 'value' => 'SOME VALUE')
               );
 
 
    print "reading webforms\n";
    $webforms = $client->readWebforms(array('pageNumber' => 1,
                                            'filter' => $filter
                                            )
                                      )->return;
 
} catch (Exception $e) {
    print "uncaught exception\n";
    print $e;
    exit();
}
 
// print matching webforms
foreach ($webforms as $webform) {
        print("ID: " . $webform->id . " Name: " . $webform->name . "\n");
 
}

Python Code Example

from suds.client import Client
from suds import WebFault
import sys
import logging
 
# Tested with Python 2.6.1 and suds soap library version 0.4
 
# See suds home page:
# https://fedorahosted.org/suds/
 
 
# Bronto API WSDL
BRONTO_WSDL = 'https://api.bronto.com/v4?wsdl'
 
# start up basic logging
logging.basicConfig()
 
TOKEN = "TOKEN HERE"
 
 
# login using the token to obtain a session ID
bApi = Client( BRONTO_WSDL )
 
try:
    session_id = bApi.service.login(TOKEN)
# just exit if something goes wrong
except WebFault, e:
   print '\nERROR MESSAGE:'
   print e
   sys.exit()
 
# Set up the soap headers using the
# session_id obtained from login()
session_header = bApi.factory.create("sessionHeader")
session_header.sessionId = session_id
bApi.set_options(soapheaders=session_header)
 
# Create the webformFilter passed into
# readWebforms()
 
filter = bApi.factory.create('webformFilter')
 
stringValue = bApi.factory.create('stringValue')
stringValue.value = 'SOME VALUE'
filterOperator = bApi.factory.create('filterOperator')
stringValue.operator = filterOperator.Contains
 
filterType = bApi.factory.create('filterType')
 
filter.name = stringValue
filter.type = filterType.AND
 
pageNumber = 1
 
try:
    webform_list = bApi.service.readWebforms(filter, pageNumber)
except WebFault, e:
    print '\nERROR MESSAGE:'
    print e
    sys.exit()
print bApi.last_sent()
print bApi.last_received()
print webform_list
for webform in webform_list:
    print 'Webform Name: ' + webform.name
    print 'Webform ID: ' + webform.id
    print 'Webform Type: ' + webform.type