addContentTags
The addContentTags
function allows you to add content tags to use in
your account.
Overview
Content tags allow you to create reusable blocks of content that you can use in the body, header, and footer of your email messages. The block is referenced via a custom defined content tag you create. When the message is sent, the content tag is replaced with the appropriate content.
Syntax
writeResult = bApi.addContentTags(contentTagObject[] contentTags);
Attributes
Name | Type | Required | Description |
---|---|---|---|
name |
string | Yes |
The name you assigned to the content tag. The name you specify will be used to
reference this block of content via the Content Tag. For example, if you name the
Content Tag mycontenttag, you would reference this Content
Tag in your message by adding
|
value |
string | Yes |
The content that will be displayed when the message is sent. Note:
|
PHP Code Example
<?php /** * This script will add a content tag. * Be sure to replace all the generic placeholder text! * * @copyright Copyright (c) 2013 Bronto Software (http://www.bronto.com) */ $client = new SoapClient('https://api.bronto.com/v4?wsdl', array('trace' => 1, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS)); try { $token = "ADD 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)); $contentTagObject = array('name' => 'EXAMPLE NAME', 'value' => 'EXAMPLE CONTENT' ); $write_result = $client->addContentTags(array($contentTagObject))->return; if ($write_result->errors) { print "There was a problem adding the content tag:\n"; print_r($write_result->results); } else { print "The content tag has been created. Id: " . $write_result->results[0]->id . "\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 add 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 = "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) # Adding a content tag # Be sure to replace the placeholder text with a # real email address! contentTag = bApi.factory.create('contentTagObject') contentTag.name = 'examplecontenttag' contentTag.value = "Here is some example text" try: addcontentTag = bApi.service.addContentTags(contentTag) if addcontentTag.results[0].isError == True: print 'There was an error with your request:' print addcontentTag.results[0] sys.exit() else: print 'A content tag has been added with the id: ' + addcontentTag.results[0].id except WebFault, e: print '\nERROR MESSAGE:' print e sys.exit()