Back to Documentation Overview

campaignTemplates

public static campaignTemplates(string apikey)

Retrieve all templates defined for your user account

Section:
Campaign Related
Parameters:
apikey a valid API Key for your user account. Get by calling login()
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

  1. <?php
  2. /**
  3. This Example shows how to retrieve a list of your Campaign Templates
  4. via the MCAPI class.
  5. **/
  6. require_once 'inc/MCAPI.class.php';
  7. require_once 'inc/config.inc.php'; //contains apikey
  8.  
  9. $api = new MCAPI($apikey);
  10.  
  11. $retval = $api->campaignTemplates();
  12.  
  13. if ($api->errorCode){
  14. echo "Unable to Load Templates!";
  15. echo "\n\tCode=".$api->errorCode;
  16. echo "\n\tMsg=".$api->errorMessage."\n";
  17. } else {
  18. echo "Your templates:\n";
  19. foreach($retval as $tmpl){
  20. echo $tmpl['id']." - ".$tmpl['name']." - ".$tmpl['layout']."\n";
  21. }
  22. }
  23.  

[2] xml-rpc_campaignTemplates.php

  1. <?php
  2. /**
  3. This Example shows how to Retrieve all of your Campaign Templates using the XML-RPC service
  4. and do some basic error checking.
  5. Note that we are using the PEAR XML-RPC client and recommend others do as well.
  6. **/
  7. require_once 'XML/RPC2/Client.php';
  8. require_once 'inc/config.inc.php';
  9. try {
  10. $client = XML_RPC2_Client::create($apiUrl);
  11.  
  12. $result = $client->campaignTemplates($apikey);
  13. echo "SUCCESS! \n";
  14. echo "Your templates:\n";
  15. foreach($result as $tmpl){
  16. echo $tmpl['id']." - ".$tmpl['name']." - ".$tmpl['layout']."\n";
  17. }
  18. } catch (XML_RPC2_FaultException $e){
  19. echo "ERROR!!!!\n";
  20. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  21. }
  22. echo "\n";
  23.  
  24.  
Add New Note User Contributed Notes for campaignTemplates
No notes, yet... Will you be the first??