campaignTemplates()

Submit request and as a result obtain a list (array) with saved templates in user’s account.

campaignTemplates(integer $start, integer $limit) : array
Input parameters
  • start - page number starting from which selection will be made (optional). Default value is 0.
  • limit - number of results returned in one page(optional). Default value is 25. Maximum allowable value is 100.
 
Information obtained

Array of Templates. Each template is represented as an array that includes:

  • id - template ID
  • name - name of template
  • layout - template layout (basic, left column, right column, postcard)
  • preview_image - picture of template (URL of the picure)
  • source - template HTML code

Examples

mgapi_campaignTemplates.php
campaignTemplates();
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignTemplates()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "Your templates:\n";
    foreach ($retval as $tmpl) {
        echo "\t" . $tmpl['id'] . " - " . $tmpl['name'] . " - " . $tmpl['layout'] . "\n";
    }
}
xml-rpc_campaignTemplates.php
 new xmlrpcval($apikey)
                ),
                'struct');
$f = new xmlrpcmsg('campaignTemplates', array($v));
$c = new xmlrpc_client($apiUrl["path"], $apiUrl['host'], 80);
$c->setDebug($debug);
$r = &$c->send($f);
 
header("Content-Type: text/plain");
if (!$r->faultCode()) {
    $retval = php_xmlrpc_decode($r->value());
    echo "Your templates:\n";
    foreach ($retval as $tmpl) {
        echo "\t" . $tmpl['id'] . " - " . $tmpl['name'] . " - " . $tmpl['layout'] . "\n";
    }
} else {
    echo "Unable to run campaignTemplates()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignTemplates.py
from lib.config import * #contains apikey
from lib.MGAPI import MGAPI
 
# This Example shows how to ping using the MGAPI.php class and do some basic error checking.
 
api = MGAPI(apikey)
 
retval = api.campaignTemplates()
if api.errorCode:
    print "Unable to load campaignTemplates()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Your templates:"
    for tmpl in retval:
        print "\t", tmpl['id'], " - ", tmpl['name'], " - ", tmpl['layout']

© 2010-2017 Mailigen. All rights reserved.