Array of recipients’ emails with settings and merge fields are passed, but information (also array) about how many emails have been added to a specific list is returned.
listBatchSubscribe(string $id, array $batch, boolean $double_optin, boolean $update_existing) : struct
Array consisting of:
$my_email, 'FNAME' => 'Joe'); $batch[] = array('EMAIL' => $boss_man_email, 'FNAME' => 'Boss'); $double_optin = true; $update_existing = false; $retval = $api->listBatchSubscribe($id, $batch, $double_optin, $update_existing); header("Content-Type: text/plain"); if ($api->errorCode) { echo "Unable to load listBatchSubscribe()!\n"; echo "\tCode=" . $api->errorCode . "\n"; echo "\tMsg=" . $api->errorMessage . "\n"; } else { echo "success:" . $retval['success_count'] . "\n"; echo "errors:" . $retval['error_count'] . "\n"; foreach ($retval['errors'] as $val) { echo "\t*" . $val['email'] . " failed\n"; echo "\tcode:" . $val['code'] . "\n"; echo "\tmsg :" . $val['message'] . "\n\n"; } }
new xmlrpcval($apikey), 'id' => new xmlrpcval($listId), 'batch' => php_xmlrpc_encode( array( array('EMAIL' => $my_email, 'FNAME' => 'Joe'), array('EMAIL' => $boss_man_email, 'FNAME' => 'Boss') ) ), 'double_optin' => new xmlrpcval(true), 'update_existing' => new xmlrpcval(false) ), 'struct'); $f = new xmlrpcmsg('listBatchSubscribe', 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 "success:" . $retval['success_count'] . "\n"; echo "errors:" . $retval['error_count'] . "\n"; foreach ($retval['errors'] as $val) { echo "\t*" . $val['email'] . " failed\n"; echo "\tcode:" . $val['code'] . "\n"; echo "\tmsg :" . $val['message'] . "\n\n"; } } else { echo "Unable to load listBatchSubscribe()!"; 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 batch = [] batch.append({'EMAIL': my_email, 'FNAME': 'Joe'}) batch.append({'EMAIL': boss_man_email, 'FNAME': 'Boss'}) double_optin = True update_existing = False retval = api.listBatchSubscribe(id, batch, double_optin, update_existing) if api.errorCode: print "Unable to load listBatchSubscribe()!" print "\tCode=", api.errorCode print "\tMsg=", api.errorMessage else: print "success:", retval['success_count'] print "errors:", retval['error_count'] for val in retval['errors']: print "\t*", val['email'], " failed" print "\tcode:", val['code'] print "\tmsg :", val['message']