« Back to Documentation Overview

listMergeVars – v1.2

 listMergeVars(string apikey, string id)

Get the list of merge tags for a given list, including their name, tag, and required setting

Section
List Related
xml-rpc_listMergeVars.php
Parameters
apikey a valid API Key for your user account. Get by visiting your API dashboard
id the list id to connect to. Get by calling lists()
Returns
array list of merge tags for the list
Returned Fields
stringnameName of the merge field
boolreqDenotes whether the field is required (true) or not (false)
stringfield_typeThe "data type" of this merge var. One of: email, text, number, radio, dropdown, date, address, phone, url, imageurl
boolpublicWhether or not this field is visible to list subscribers
boolshowWhether the list owner has this field displayed on their list dashboard
stringorderThe order the list owner has set this field to display in
stringdefaultThe default value the list owner has set for this field
stringsizeThe width of the field to be used
stringtagThe merge tag that's used for forms and listSubscribe() and listUpdateMember()
arraychoicesFor radio and dropdown field types, an array of the options available

Examples (1)

download example code

[1] xml-rpc_listMergeVars.php

  1. <?php
  2. /**
  3. This Example shows how retrieve the setup of your Merge Variables for a list
  4. using XML-RPC.
  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->listMergeVars($apikey, $listId);
  13. echo "SUCCESS! \n";
  14. foreach($result as $i=>$var){
  15. echo "Var #$i:\n";
  16. echo "\tTag: ". $var['tag']."\n";
  17. echo "\tName: ". $var['name']."\n";
  18. echo "\tRequired: ". $var['req']."\n";
  19.  
  20. }
  21. } catch (XML_RPC2_FaultException $e){
  22. echo "ERROR!!!!\n";
  23. echo 'code: '.$e->getFaultCode()."\n";
  24. echo 'msg : '.$e->getFaultString()."\n";
  25. }
  26. echo "\n";
  27.  
  28. ?>
  29.