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'])

© 2010-2017 Mailigen. All rights reserved.