readContentTags
The readContentTags
function attempts to return content tags that match all parameters of the given filter. The specific attributes of the content tags are returned for each matching content tag.
Results
The readContentTags function may return 1 or many content tag objects. See the documentation on the contentTagObject to view the data that could potentially be returned.
Syntax
contentTagObject[] contentTags = bApi.readContentTags(filter contentTagFilter,
pageNumber);
Parameters
Name | Type | Required | Comments |
---|---|---|---|
filter |
contentTagFilter | Yes | The filter used to return specific content tags. |
includeContent |
boolean | Yes | Set to true if you want to return the content specified for the content tag in
it’s value property |
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 script will return data for content tags whose name * matches the filter */ $client = new SoapClient('https://api.bronto.com/v4?wsdl', array('trace' => 1, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS)); try { $token = "API 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 content tags $filter = array('type' => 'AND', 'name' => array('operator' => 'Contains', 'value' => 'SOME EXAMPLE TEXT') ); print "reading all content tags\n"; $tags = $client->readContentTags(array('pageNumber' => 1, 'filter' => $filter, 'includeContent' => true))->return; // print matching tag id, name, and value. foreach ($tags as $tag) { print "ID: " . $tag->id . "\n"; print "Name: " . $tag->name . "\n"; print "Value: " . $tag->value . "\n"; } } catch (Exception $e) { print "uncaught exception\n"; print_r($e); }
Python Code Example
import sys import logging from suds.client import Client from suds import WebFault # This example script will login in to the API and read data # for a content tag # BE SURE TO REPLACE ALL PLACEHOLDER TEXT # Tested with Python 2.7.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() # Replace the placeholder text with a valid # API token TOKEN = "ADD API 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 contentTagsFilter passed into # readContentTags() filter = bApi.factory.create('contentTagFilter') stringValue = bApi.factory.create('stringValue') stringValue.value = 'example' filterOperator = bApi.factory.create('filterOperator') stringValue.operator = filterOperator.Contains filterType = bApi.factory.create('filterType') # To search by ID, remove the code on line 62, and # comment out the line below: # filter.id = 'THE ID OF THE CONTENT TAG' filter.name = stringValue filter.type = filterType.AND pageNumber = 1 includeContent = True try: contentTag = bApi.service.readContentTags(filter, includeContent, pageNumber) except WebFault, e: print '\nERROR MESSAGE:' print e sys.exit() print bApi.last_sent() print bApi.last_received() print contentTag for tag in contentTag: print 'Content Tag ID: ' + tag.id print 'Content Tag Name: ' + tag.name print 'Content Tag Value: ' + tag.value