« Back to Documentation Overview

listMergeVarAdd – v1.3

 listMergeVarAdd(string apikey, string id, string tag, string name, array options)

Add a new merge tag to a given list

Section
List Related
xml-rpc_listMergeVarAdd.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()
tag The merge tag to add, e.g. FNAME. 10 bytes max, valid characters: "A-Z 0-9 _" no spaces, dashes, etc.
name The long description of the tag being added, used for user displays
options optional - Various options for this merge var. note: for historical purposes this can also take a "boolean"
stringfield_typeoptional - one of: text, number, radio, dropdown, date, address, phone, url, imageurl, zip, birthday - defaults to text
booleanreqoptional - indicates whether the field is required - defaults to false
booleanpublicoptional - indicates whether the field is displayed in public - defaults to true
booleanshowoptional - indicates whether the field is displayed in the app's list member view - defaults to true
stringdefault_valueoptional - the default value for the field. See listSubscribe() for formatting info. Defaults to blank
arraychoicesoptional - kind of - an array of strings to use as the choices for radio and dropdown type fields
stringdateformatoptional - only valid for birthday and date fields. For birthday type, must be "MM/DD" (default) or "DD/MM". For date type, must be "MM/DD/YYYY" (default) or "DD/MM/YYYY". Any other values will be converted to the default.
stringphoneformatoptional - "US" is the default - any other value will cause them to be unformatted (international)
stringdefaultcountryoptional - the ISO 3166 2 digit character code for the default country. Defaults to "US". Anything unrecognized will be converted to the default.
Returns
bool true if the request succeeds, otherwise an error will be thrown

Examples (1)

download example code

[1] xml-rpc_listMergeVarAdd.php

  1. <?php
  2. /**
  3. This Example shows how to add an Merge Variable to a list using XML-RPC.
  4. Note that we are using the PEAR XML-RPC client and recommend others do as well.
  5. **/
  6. require_once 'XML/RPC2/Client.php';
  7. require_once 'inc/config.inc.php';
  8. try {
  9. $client = XML_RPC2_Client::create($apiUrl);
  10.  
  11. $result = $client->listMergeVarAdd($apikey, $listId, 'TEST','Testing', false);
  12. echo "SUCCESS! \n";
  13. echo "Returned: $result\n";
  14. } catch (XML_RPC2_FaultException $e){
  15. echo "ERROR!!!!\n";
  16. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  17. }
  18.  
  19. ?>
  20.