listMembersByMerge()

You can obtain collection of emails (array) for a specific list by performing a search with given merge field value.

listMembersByMerge(string $id, string $merge_var, string $merge_value, string $status, integer $start, integer $limit) : array
Input parameters
  • id - list ID
  • merge_var - name of the merge field to use in a search.
  • merge_value - exact value that given merge field holds. Empty value is used by default.
  • status - email status (unsubscribed, inactive, bounced, subscribed) (optional). Default value is subscribed.
  • start - page number starting from which selection will be made (optional). Default value is 0.
  • limit - number of results returned in one page (optional). Default value is 25. Maximum allowable value is 15000.

Information obtained

Array of members. Each member is represented as an array consisting of:

  • id - ID of the email address
  • email - email address
  • timestamp - date of adding email to the list in timestamp format

Examples

mgapi_listMembersByMerge.php
<?php
/**
 * This Example shows how to listMembersByMerge using the MGAPI.php class and do some basic error checking.
 */
require_once 'inc/MGAPI.class.php';
require_once 'inc/config.inc.php'; //contains apikey
 
$api = new MGAPI($apikey);
 
$id = $listId;
$merge_var = "FNAME";
$merge_value = "Fname";
$status = "subscribed";
$start = 0;
$limit = 500;
 
$retval = $api->listMembersByMerge($id, $merge_var, $merge_value, $status, $start, $limit);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load listMembersByMerge()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "Members returned: " . sizeof($retval) . "\n";
    foreach ($retval as $member) {
        echo "\t" . $member['email'] . " - " . $member['timestamp'] . "\n";
    }
}

© 2010-2017 Mailigen. All rights reserved.