Sending a campaign

campaigns()

Campaign list is returned by request. When sending a request, it is possible to perform data selection due to which campaigns will be returned from the database. Selection parameters are transferred, while campaign list (array) is returned. If selection parameters are not transferred, information about all campaigns is returned.

campaigns(array $filters, integer $start, integer $limit) : array
Input parameters
  • filters - selection parameters (optional). Array consisting of any of following parameters:
    • campaign_id - campaign ID (optional)
    • list_id - list ID (optional)
    • status - status of campaign (sent, draft, paused, sending) (optional)
    • type - type of campaign (plain, HTML) (optional)
    • from_name - sender name (optional)
    • from_email - sender email (optional)
    • title - name of campaign (optional)
    • subject - subject line (optional)
    • sendtime_start - sending time before (campaigns sent before a specific date are selected) (optional)
    • sendtime_end - sending time after (campaigns sent after a specific date are selected) (optional)
  • 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 1000.

Information obtained

Array of campaigns. Each campaign is represented as an array that includes:

  • id - campaign ID used in other API functions
  • web_id - campaign ID for web version (used for URL link from archive)
  • title - name of campaign
  • type - type of campaign (HTMP, plain text, auto)
  • create_time - date of creating campaign
  • send_time - date of sending campaign
  • emails_sent - number of sent emails
  • status - status of campaign (sent, draft, paused, sending)
  • from_name - sender name
  • from_email - sender email
  • subject - subject line
  • to_email - personalization of ‘To’ field (true, false)
  • archive_url - link of campaign archive
  • analytics - whether Google Analytics tool is integrated (true, false)
  • analytcs_tag - name of Google Analytics campaign
  • track_clicks_text - whether clicks of plain text email are counted (true, false)
  • track_clicks_html - whether clicks of HTML email are counted (true, false)
  • track_opens - whether email opening is counted (true, false)

Examples

mgapi_campaigns.php
campaigns();
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaigns()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo sizeof($retval) . " Campaigns Returned:\n";
    foreach ($retval as $c) {
        echo "Campaign Id: " . $c['id'] . " - " . $c['title'] . "\n";
        echo "\tStatus: " . $c['status'] . " - type = " . $c['type'] . "\n";
        echo "\tsent: " . $c['send_time'] . " to " . $c['emails_sent'] . " members\n";
    }
}
mgapi_campaigns.py
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)
 
retval = api.campaigns()
 
if api.errorCode:
    print "Unable to load campaigns()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "%d Campaigns Returned:" % (len(retval))
    for c in retval:
        print "Campaign Id: %s - %s" % (c['id'], c['title'])
        print "\tStatus: %s - type = %s" % (c['status'], c['type'])
        print "\tsent: %s to %s members" % (c['send_time'], c['emails_sent'])

campaignCreate()

New campaign is created and array of parameters is passed including information about type of campaign, campaign settings, email content and autoresponder campaign if such is created.

campaignCreate(string $type, array $options, array $content, array $type_opts) : string
Input parameters
  • type - type of campaign (HTML, plain, auto)
  • options - campaign settings. Array consisting of: 
    • list_id - list ID or array of multiple lists IDs
    • segment_id - segment ID or array of multiple segment IDs (optional). User created segment based only on given list ID.
      id parameter value must be used here. See All segments for retrieving segment ID value.
    • subject - subject line
    • from_email - reply To email address. Recipient replies will go to this email address.
    • from_name - sender's name, from who the campaign will be received.
    • sender - sender email (optional). Specify an e-mail address from which the campaign will be received. Only available for PRO Users. Your main e-mail address is used by default.
    • tracking - campaign tracking (optional). Array of boolean values for following options:
      • opens - (true, false). Default value is true.
      • html_clicks - (true, false). Default value is true.
      • text_clicks - (true, false). Default value is false.
    • title - name of campaign (optional). By default subject line is used as a name of campaign
    • analytics - web analytics integration option (optional). Array of options for given web analytics tool. 
    • enerate_text - plain text generation (true, false) (optional). If set to true, text from HTML will be generated. Default value is false.
    • auto_footer - whether to send out the campaign with a standard signature (true, false) (optional). Default value is false.
    • authenticate - authenticate the campaign (true, false) (optional). Will work if authenticated and activated domains are added to system. Default value is false.
    • inline_img - send images as attachment - inline images (true, false) (optional). Default value is false. Only available for users with Inline image add-on.
    • time_match - use time match to deliver scheduled campaigns based on recipient's time zone (true, false). Default value is false.
    • ln - text language (cn, dk, en, ee, fi, fr, de, it, jp, lv, lt, no, pl, pt, ru, es, se) (optional). Specify language for texts by including header and footer.
  • content - campaign email content. Array consisting of:
    • html - HTML content.
    • plain - plain text content. If this value is omitted, then plain text generation option should be switched on (set to true), to ensure there is a plain text content.OR
    • url - URL from which import HTML. If parameter plain is omitted, then generate_text option should be switched on (set to true), to ensure there is a plain text content.
    • plain - plain text content. If this value is omitted, then generate_text option should be switched on (set to true), to ensure there is a plain text content.OR
    • archive - archive file encoded with with Base64. If this value is set, above values will be overwritten.
    • archive_type - archive type (optional). Following archive formats are supported: zip, tar.gz, tar.bz2, tar, tgz, tbz. By default zip format is used, if no value is set.OR
    • template_id - user defined template ID to be used for generating HTML content of the email
  • type_opts - autoresponder campaign settings (optional). Array consisting of:
    • offset-units - time unit of autoresponder (day, week, month, year). One of the given values must be specified.
    • offset-time - time of autoresponder. Value greather than 0 (zero) must be specified.
    • offset-dir - moment of sending (before, after). Default value is after.
    • event - event (signup, date, annual) after which autoresponder campaign is sent (optional). Default value is signup.
    • event-datemerge - merge tag that is taken into account when sending campaign (optional). This option has to be set when chosen event option is "date" or "annual".

Information obtained
  • ID of the new campaign

Examples

mgapi_campaignCreate.php
 $listId,
    //'segment_id' => 'YOUR_SEGMENT_ID',
    'subject' => 'Test Newsletter Subject',
    'from_email' => 'example@example.org',
    'from_name' => 'DEMO, Inc.',
    //'sender' => 'example@example.org', // This Email Sender Information will be used (Only available for PRO Users)
    'tracking' => array(
        'opens' => true,
        'html_clicks' => true,
        'text_clicks' => false
    ),
    'analytics' => array(
        'google' => 'my_google_analytics_key'
    ),
    'title' => 'Test Newsletter Title'
);
/*
$content = array(
    'template_id' => 'template_id',
);
*/
/*
$content = array(
    'html' => 'some pretty html content *[UNSUB]* message',
    'plain' => 'some pretty plain content *[UNSUB]* message',
);
*/
/*
$content = array(
    'url' => 'http://www.google.com',
    'plain' => 'some pretty plain content *[UNSUB]* message',
);
*/
$content = array(
    'archive' => base64_encode(file_get_contents('archive.tar')),
    'archive_type' => 'tar'
);
 
 
 
 
$retval = $api->campaignCreate($type, $options, $content);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignCreate()!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "New Campaign ID:" . $retval . "\n";
}
xml-rpc_campaignCreate.php
 new xmlrpcval($apikey),
                    'type' => new xmlrpcval('html'),
                    'options' => php_xmlrpc_encode(
                            array(
                                'list_id' => $listId,
                                'subject' => 'Test Newsletter Subject',
                                'from_email' => 'example@example.org',
                                'from_name' => 'DEMO, Inc.',
                                'tracking' => array(
                                    'opens' => true,
                                    'html_clicks' => true,
                                    'text_clicks' => false
                                ),
                                'analytics' => array(
                                    'google' => 'my_google_analytics_key'
                                ),
                                'title' => 'Test Newsletter Title'
                            )
                    ),
                    'content' => php_xmlrpc_encode(
                            array(
                                //'template_id' => 'template_id',
                                //'html' => 'some pretty html content *[UNSUB]* message',
                                //'plain' => 'some pretty plain content *[UNSUB]* message',
                                //'url' => 'http://www.google.com',
                                'archive' => base64_encode(file_get_contents('archive.tar')),
                                'archive_type' => 'tar'
                            )
                    )
                ),
                'struct');
$f = new xmlrpcmsg('campaignCreate', 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 "New Campaign ID:" . $retval . "\n";
} else {
    echo "Unable to run campaignCreate()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}

mgapi_campaignCreate.py
from lib.config import * #contains apikey
from lib.MGAPI import MGAPI
import base64
 
# This Example shows how to ping using the MGAPI.php class and do some basic error checking.
 
api = MGAPI(apikey)
 
type = 'html'
options = {
    'list_id': listId,
    'subject': 'Test Newsletter Subject',
    'from_email': 'example@example.org',
    'from_name': 'DEMO, Inc.',
    'tracking': {
        'opens': True,
        'html_clicks': True,
        'text_clicks': False
    },
    'analytics': {
        'google': 'my_google_analytics_key'
    },
    'title': 'Test Newsletter Title'
}
content = {
    #'template_id': 'template_id',
    #'html': 'some pretty html content *[UNSUB]* message',
    #'plain': 'some pretty plain content *[UNSUB]* message',
    #'url': 'http://www.google.com',
    'archive': base64.encodestring(open('archive.zip').read()),
    'archive_type': 'zip'
}
 
retval = api.campaignCreate(type, options, content)
if api.errorCode:
    print "Unable to load campaignCreate()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "New Campaign ID:", retval

campaignUpdate()

Update of one of the previously created values of campaign parameters.

Works if campaign is not yet sent.
campaignUpdate(string $cid, string $name, mixed $value) : boolean
Input parameters
  • cid - campaign ID
  • name - name of parameter (see Creation of new campaign possible parameter names)
  • value - value of parameter (see Creation of new campaign possible parameter values)
    If list ID is used, all of the previous lists will be deleted.
    If template ID is used, HTML content will be overwritten by content of the given template.

Information obtained
  • true, if parameter update has succeeded. Otherwise, an error message is returned.

Examples

mgapi_campaignUpdate.php
campaignUpdate($cid, $name, $value);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignUpdate()!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "SUCCESS! \n";
}
xml-rpc_campaignUpdate.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId),
                    'name' => new xmlrpcval('title'),
                    'value' => new xmlrpcval('New Title')
                ),
                'struct');
$f = new xmlrpcmsg('campaignUpdate', 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! \n";
} else {
    echo "Unable to run campaignUpdate()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignUpdate.py
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)
 
cid = campaignId
name = 'title'
value = 'New Title'
 
retval = api.campaignUpdate(cid, name, value)
if api.errorCode:
    print "Unable to load campaignUpdate()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "SUCCESS!"

campaignSendNow()

Submit request of delivering campaign that previously was saved as a draft. Campaign is sent immediately. Campaign ID number is passed as a parameter.

campaignSendNow(string $cid) : boolean
Input parameters
  • cid - campaign ID

Information obtained
  • true, if request of campaign delivery has succeeded. Otherwise, an error message is returned.

Examples

mgapi_campaignSendNow.php
campaignSendNow($cid);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignSendNow()!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "Campaign Sent!\n";
}
xml-rpc_campaignSendNow.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId)
                ),
                'struct');
$f = new xmlrpcmsg('campaignSendNow', 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 "Campaign Sent!\n";
} else {
    echo "Unable to run campaignSendNow()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignSendNow.py
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)
cid = campaignId
 
retval = api.campaignSendNow(cid)
if api.errorCode:
    print "Unable to load campaignSendNow()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Campaign Sent!"

campaignSchedule()

Campaign delivery is scheduled. Time is set according GMT, but if a specific time zone needs to be set up, required number of hours have to be added or subtracted. Time is written in YYYY-MM-DD HH:II:SS +GMT format. Example of time format: ‘2020-05-18 11:59:21 +0100’, where ‘+0100’ is an added hour to the standard time.

campaignSchedule(string $cid, string $schedule_time) : boolean
Input parameters
  • cid - campaign ID
  • schedule_time - sending time (according to GMT)

Information obtained
  • true, if scheduling has succeeded. Otherwise, an error message is returned.

Examples

mgapi_campaignSchedule.php
campaignSchedule($cid, $schedule_time);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignSchedule()!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "Campaign Scheduled to be delivered $schedule_time!\n";
}
xml-rpc_campaignSchedule.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId),
                    'schedule_time' => new xmlrpcval($schedule_time)
                ),
                'struct');
$f = new xmlrpcmsg('campaignSchedule', 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 "Campaign Scheduled to be delivered $schedule_time!\n";
} else {
    echo "Unable to run campaignSchedule()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignSchedule.py
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)
 
cid = campaignId
schedule_time = '2020-05-18 11:59:21'
 
retval = api.campaignSchedule(cid, schedule_time)
if api.errorCode:
    print "Unable to load campaignSchedule()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Campaign Scheduled to be delivered %s!" % (schedule_time)

campaignUnschedule()

Campaign delivery time is unscheduled. Campaign is saved as a draft and is not delivered.

campaignUnschedule(string $cid) : boolean
Input parameters
  • cid - campaign ID
Information obtained
  • true, if unscheduling has succeeded. Otherwise, an error message is returned.

Examples

mgapi_campaignUnschedule.php
campaignUnschedule($cid);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignUnschedule()!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "Campaign Unscheduled!\n";
}
xml-rpc_campaignUnschedule.php
  new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId)
                ),
                'struct');
$f = new xmlrpcmsg('campaignUnschedule', 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 "Campaign Unscheduled!\n";
} else {
    echo "Unable to run campaignUnschedule()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignUnschedule.py
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)
cid = campaignId
 
retval = api.campaignUnschedule(cid)
if api.errorCode:
    print "Unable to load campaignUnschedule()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Campaign Unscheduled!"

campaignSendTest()

Submit request of delivering test mails of campaign which previously was saved as a draft.

campaignSendTest(string $cid, array $test_emails, string $send_type) : boolean
Input parameters
  • cid - campaign ID
  • test_emails - list of test emails (array)
  • send_type - sending type (HTML, plain) (optional)
Information obtained
  • true, if request of test mail delivery has succeeded. Otherwise, an error message is returned.

Examples

mgapi_campaignSendTest.php
campaignSendTest($cid, $test_emails);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignSendTest()!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "Campaign Tests Sent!\n";
}
xml-rpc_campaignSendTest.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId),
                    'test_emails' => php_xmlrpc_encode(
                        array($my_email, $boss_man_email)
                    )
                ),
                'struct');
$f = new xmlrpcmsg('campaignSendTest', 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 "Campaign Tests Sent!\n";
} else {
    echo "Unable to run campaignSendTest()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignSendTest.py
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)
 
cid = campaignId
test_emails = [my_email, boss_man_email]
 
retval = api.campaignSendTest(cid, test_emails)
if api.errorCode:
    print "Unable to load campaignSendTest()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Campaign Tests Sent!"

campaignTemplates()

Submit request and as a result obtain a list (array) with saved templates in user’s account.

campaignTemplates() : array
Information obtained

Array of Templates. Each template is represented as an array that includes:

  • id - template ID
  • name - name of template
  • layout - template layout (basic, left column, right column, postcard)
  • preview_image - picture of template (URL of the picure)
  • source - template HTML code

Examples

mgapi_campaignTemplates.php
campaignTemplates();
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignTemplates()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "Your templates:\n";
    foreach ($retval as $tmpl) {
        echo "\t" . $tmpl['id'] . " - " . $tmpl['name'] . " - " . $tmpl['layout'] . "\n";
    }
}
xml-rpc_campaignTemplates.php
 new xmlrpcval($apikey)
                ),
                'struct');
$f = new xmlrpcmsg('campaignTemplates', 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 "Your templates:\n";
    foreach ($retval as $tmpl) {
        echo "\t" . $tmpl['id'] . " - " . $tmpl['name'] . " - " . $tmpl['layout'] . "\n";
    }
} else {
    echo "Unable to run campaignTemplates()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignTemplates.py
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)
 
retval = api.campaignTemplates()
if api.errorCode:
    print "Unable to load campaignTemplates()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Your templates:"
    for tmpl in retval:
        print "\t", tmpl['id'], " - ", tmpl['name'], " - ", tmpl['layout']

campaignReplicate()

Existing campaign is replicated and the ID of the new campaign is returned.

campaignReplicate(string $cid) : string
Input parameters
  • cid - campaign ID
Information obtained
  • campaign copy ID

Examples

mgapi_campaignReplicate.php
campaignReplicate($cid);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignReplicate()!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "New Campaign Id = " . $retval . "\n";
}
xml-rpc_campaignReplicate.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId)
                ),
                'struct');
$f = new xmlrpcmsg('campaignReplicate', 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 "New Campaign Id = " . $retval . "\n";
} else {
    echo "Unable to run campaignReplicate()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignReplicate.py
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)
cid = campaignId
 
retval = api.campaignReplicate(cid)
if api.errorCode:
    print "Unable to load campaignReplicate()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "New Campaign Id = ", retval

campaignDelete()

Delete campaign from the account of a specific user.

It is not possible to restore the deleted campaign (!). By deleting campaign, campaign reports will also be deleted.
campaignDelete(string $cid) : boolean
Input parameters
  • cid - campaign ID
Information obtained
  • true, if the request for campaign delete has succeeded. Otherwise, an error message is returned.

Examples

mgapi_campaignDelete.php
campaignDelete($cid);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignDelete()!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "Campaign Deleted!\n";
}
xml-rpc_campaignDelete.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId)
                ),
                'struct');
$f = new xmlrpcmsg('campaignDelete', 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 "Campaign Deleted!\n";
} else {
    echo "Unable to run campaignDelete()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignDelete.py
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)
 
cid = campaignId
 
retval = api.campaignDelete(cid)
if api.errorCode:
    print "Unable to load campaignDelete()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Campaign Deleted!"

© 2010-2017 Mailigen. All rights reserved.