This function obtains merge fields (array) from database, as well as all the necessary parameters of these fields.
listMergeVars(string $id) : array
Array of merge fields. Each merge field is represented as an array that includes:
listMergeVars($id); header("Content-Type: text/plain"); if ($api->errorCode) { echo "Unable to load listMergeVars()!"; echo "\tCode=" . $api->errorCode . "\n"; echo "\tMsg=" . $api->errorMessage . "\n"; } else { echo "Merge tags returned: " . sizeof($retval) . "\n"; foreach ($retval as $i => $var) { echo "Var #$i:\n"; echo "\tTag: " . $var['tag'] . "\n"; echo "\tName: " . $var['name'] . "\n"; echo "\tRequired: " . $var['req'] . "\n"; } }
new xmlrpcval($apikey), 'id' => new xmlrpcval($listId) ), 'struct'); $f = new xmlrpcmsg('listMergeVars', 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 "Merge tags returned: " . sizeof($retval) . "\n"; foreach ($retval as $i => $var) { echo "Var #$i:\n"; echo "\tTag: " . $var['tag'] . "\n"; echo "\tName: " . $var['name'] . "\n"; echo "\tRequired: " . $var['req'] . "\n"; } } else { echo "Unable to run listMergeVars()!\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 retval = api.listMergeVars(id) if api.errorCode: print "Unable to load listMergeVars()!" print "\tCode=", api.errorCode print "\tMsg=", api.errorMessage else: print "Merge tags returned: ", len(retval) if isinstance(retval, dict): for i,var in retval.items(): print "Var #%d:" % (i) print "\tTag: ", var['tag'] print "\tName: ", var['name'] print "\tRequired: ", var['req'] elif isinstance(retval, list): for i,var in enumerate(retval): print "Var #%d:" % (i) print "\tTag: ", var['tag'] print "\tName: ", var['name'] print "\tRequired: ", var['req']