listCreate()

Create new list..

listCreate(string $title, array $options) : string
Input parametrs
  • title - list name
  • options - array of campaign parameters consisting of:
    • permission_reminder - reminder message for users how they got on this list
    • notify_to - email address where notificiations will be sent
    • subscription_notify - whether notification is sent that a new user has been subscribed (true, false)
    • unsubscription_notify - whether notification is sent that a new user has been unsubscribed (true, false)
    • has_email_type_option - whether user can pick email format (true, false)
    • public_title - name that will be displayed on your web sign-up forms and sign-up confirmation emails
Information obtained

Array of lists. Each list is represented as an array that includes:

  • ID of the new list

Examples

mgapi_listCreate.php
<?php
/**
 * This Example shows how to listCreate 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);
 
$title = 'Test List';
$options = array(
    'permission_reminder' =--> 'Write a short reminder about how the recipient joined your list.',
    'notify_to' => 'example@example.org',
    'subscription_notify' => true,
    'unsubscription_notify' => true,
    'has_email_type_option' => true,
    'public_title' => 'Public Name for Test List',
);
 
$retval = $api->listCreate($title, $options);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load listCreate()!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "New List ID:" . $retval . "\n";
}
xml-rpc_listCreate.php
<?php
/**
 * This Example shows how execute a listCreate and check the result using XML-RPC.
 * Note that we are using the PEAR XML-RPC client and recommend others do as well.
 */
require_once 'xmlrpc-3.0.0.beta/xmlrpc.inc';
require_once 'inc/config.inc.php';
 
$apiUrl = parse_url($apiUrl);
 
$v = new xmlrpcval(array(
                    'apikey' =--> new xmlrpcval($apikey),
                    'title' => new xmlrpcval('Test List'),
                    'options' => php_xmlrpc_encode(
                            array(
                                "permission_reminder" => 'Write a short reminder about how the recipient joined your list.',
                                "notify_to" => 'example@example.org',
                                "subscription_notify" => true,
                                "unsubscription_notify" => true,
                                "has_email_type_option" => true
                            )
                    )
                ),
                'struct');
$f = new xmlrpcmsg('listCreate', 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 listCreate()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}

© 2010-2017 Mailigen. All rights reserved.