This function adds a new merge field to a particular list in the database adding also the name and settings of this field.
listMergeVarAdd(string $id, string $tag, string $name, array $options) : boolean
Male||Female||Prefer not to say
array('values' => array('M', 'F'), 'labels' => array('Male', 'Female'))
Array of merge fields. Each merge field is represented as an array that includes:
'text', "req" => false, "default_value" => 'Default value', "show" => true ); $retval = $api->listMergeVarAdd($id, $tag, $name, $options); header("Content-Type: text/plain"); if ($api->errorCode) { echo "Unable to load listMergeVarAdd()!\n"; echo "\tCode=" . $api->errorCode . "\n"; echo "\tMsg=" . $api->errorMessage . "\n"; } else { echo "Returned: " . $retval . "\n"; }
new xmlrpcval($apikey), 'id' => new xmlrpcval($listId), 'tag' => new xmlrpcval('MERGE_TAG'), 'name' => new xmlrpcval('Merge Tag name'), 'options' => php_xmlrpc_encode( array( "field_type" => 'text', "req" => false, "default_value" => 'Default value', "show" => true ) ) ), 'struct'); $f = new xmlrpcmsg('listMergeVarAdd', 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 "Returned: " . $retval . "\n"; } else { echo "Unable to load listMergeVarAdd()!\n"; echo "\tCode=" . $r->faultCode() . "\n"; echo "\tMsg=" . $r->faultString() . "\n"; }
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) id = listId tag = 'MERGE_TAG' name = 'Merge Tag name' options = { "field_type": 'text', "req": False, "default_value": 'Default value', "show": True } retval = api.listMergeVarAdd(id, tag, name, options) if api.errorCode: print "Unable to load listMergeVarAdd()!" print "\tCode=", api.errorCode print "\tMsg=", api.errorMessage else: print "Returned: ", retval