« Back to Documentation OverviewcampaignTemplates – v1.1
campaignTemplates(string apikey)
Retrieve all templates defined for your user account
| Parameters | | apikey a valid API Key for your user account. Get by calling Get by visiting your API dashboard |
| Returns | | array |
An array of structs, one for each template (see Returned Fields for details) |
| Returned Fields | integer | id | Id of the template | string | name | Name of the template | string | layout | Layout of the template - "basic", "left_column", "right_column", or "postcard" | array | sections | associative array of editable sections in the template that can accept custom HTML when sending a campaign |
Examples (2)
download example code
[1] mcapi_campaignTemplates.php
<?php
/**
This Example shows how to retrieve a list of your Campaign Templates
via the MCAPI class.
**/
require_once 'inc/MCAPI.class.php';
require_once 'inc/config.inc.php'; //contains apikey
$api = new MCAPI($apikey);
$retval = $api->campaignTemplates();
if ($api->errorCode){
echo "Unable to Load Templates!"; echo "\n\tCode=".$api->errorCode; echo "\n\tMsg=".$api->errorMessage."\n"; } else {
echo "Your templates:\n"; foreach($retval as $tmpl){
echo $tmpl['id']." - ".$tmpl['name']." - ".$tmpl['layout']."\n"; }
}
[2] xml-rpc_campaignTemplates.php
<?php
/**
This Example shows how to Retrieve all of your Campaign Templates using the XML-RPC service
and do some basic error checking.
Note that we are using the PEAR XML-RPC client and recommend others do as well.
**/
require_once 'XML/RPC2/Client.php';
require_once 'inc/config.inc.php';
try {
$result = $client->campaignTemplates($apikey);
echo "Your templates:\n"; foreach($result as $tmpl){
echo $tmpl['id']." - ".$tmpl['name']." - ".$tmpl['layout']."\n"; }
} catch (XML_RPC2_FaultException $e){
echo $e->getFaultCode()." : ".$e->getFaultString()."\n"; }