Exemple #1
0
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.getAccountDetails()

if api.errorCode:
    print "Unable to get account info!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Returned"
    for key, value in retval.items():
        if isinstance(value, dict):
            print "\t", key
            for k, v in value.items():
                if isinstance(v, dict):
                    print "\t\t%d" % (k + 1)
                    for k_, v_ in v.items():
                        print "\t\t\t", k_, " = ", v_
                elif isinstance(v, list):
                    print "\t\t%d" % (k + 1)
                    for k_, v_ in enumerate(v):
                        print "\t\t\t", k_, " = ", v_
                else:
                    print "\t\t", k, " = ", v
        elif isinstance(value, list):
            print "\t", key
            for k, v in enumerate(value):
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']
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': '*****@*****.**',
	'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',
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;
emails = [my_email, boss_man_email]
delete_member = False
send_goodbye = True
send_notify = False

retval = api.listBatchUnsubscribe(id, emails, delete_member, send_goodbye, send_notify)
if api.errorCode:
	print "Unable to load listBatchUnsubscribe()!"
	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']
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
tag = 'MERGE_TAG'
name = 'Merge Tag name'
options = {
    "field_type": 'text',
    "req": False,
    "default_value": 'Default value',
    "show": True
}

retval = api.listMergeVarAdd(id, tag, name, options)
if api.errorCode:
    print "Unable to load listMergeVarAdd()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Returned: ", retval
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
start = 0
limit = 1000

retval = api.campaignHardBounces(cid, start, limit)
if api.errorCode:
    print "Unable to load campaignHardBounces()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "E-mails returned: %d" % (len(retval))
    for email in retval:
        print "\t", email
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.campaignResume(cid)
if api.errorCode:
    print "Unable to load campaignResume()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Campaign Resumed!"
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.lists()


if api.errorCode:
	print "Unable to load lists()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Lists returned: %d" % (len(retval))
	for list in retval:
		print "Id = %s - %s" % (list["id"], list["name"])
Exemple #9
0
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)

username = "******"
password = "******"
expired = False

retval = api.apikeys(username, password, expired)
if api.errorCode:
    print "Unable to get API keys!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "All API Keys for your account:"
    for key in retval:
        print "key = ", key['apikey']
        print "\tcreated: = ", key['created_at']
        print "\texpired: = ", key['date_expired']
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
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)

username = "******"
password = "******"
expired = False

retval = api.apikeys(username, password, expired)
if api.errorCode:
	print "Unable to get API keys!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "All API Keys for your account:"
	for key in retval:
		print "key = ", key['apikey']
		print "\tcreated: = ", key['created_at']
		print "\texpired: = ", key['date_expired']
Exemple #12
0
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'])
Exemple #13
0
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.ping()

if api.errorCode:
    print "Unable to ping!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Returned: ", retval
Exemple #14
0
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
email_address = my_email
merge_vars = {'EMAIL': my_email, 'FNAME': 'Joe'} # or merge_vars = {}
email_type = 'html'
double_optin = True
update_existing = False
send_welcome = False

retval = api.listSubscribe(id, email_address, merge_vars, email_type, double_optin, update_existing, send_welcome)
if api.errorCode:
	print "Unable to load listSubscribe()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Returned: ", retval
Exemple #15
0
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

retval = api.listMergeVars(id)
if api.errorCode:
    print "Unable to load listMergeVars()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Merge tags returned: ", len(retval)
    if isinstance(retval, dict):
        for i, var in retval.items():
            print "Var #%d:" % (i)
            print "\tTag: ", var['tag']
            print "\tName: ", var['name']
            print "\tRequired: ", var['req']
    elif isinstance(retval, list):
        for i, var in enumerate(retval):
            print "Var #%d:" % (i)
            print "\tTag: ", var['tag']
            print "\tName: ", var['name']
            print "\tRequired: ", var['req']
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.campaignPause(cid)
if api.errorCode:
	print "Unable to load campaignPause()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Campaign Paused!"
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
start = 0
limit = 25

retval = api.campaignBounceMessages(cid, start, limit)
if api.errorCode:
	print "Unable to load campaignBounceMessages()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Messages returned: %d" % (len(retval))
	for msg in retval:
		print "%s - %s" % (msg['date'], msg['email'])
		print msg['message'][0:150]
Exemple #18
0
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

retval = api.listGrowthHistory(id)
if api.errorCode:
    print "Unable to load listGrowthHistory()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    for history in retval:
        print history['month']
        print "\tExisting=", history['existing']
        print "\tImports=", history['imports']
Exemple #19
0
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!"
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.campaignResume(cid)
if api.errorCode:
	print "Unable to load campaignResume()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Campaign Resumed!"
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
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
start = 0
limit = 1000

retval = api.campaignSoftBounces(cid, start, limit)
if api.errorCode:
	print "Unable to load campaignSoftBounces()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "E-mails returned: %d" % (len(retval))
	for email in retval:
		print "\t", email
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!"
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!"
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)

username = "******"
password = "******"

retval = api.apikeyExpire(username, password)
if api.errorCode:
	print "Unable to expire API key!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Returned: ", retval
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.campaignEmailDomainPerformance(cid)
if api.errorCode:
	print "Unable to load campaignEmailDomainPerformance()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	if len(retval) == 0:
		print "No Email Domain stats yet!"
	else:
		for domain in retval:
			print domain['domain']
			print "\tEmails: ", domain['emails']
			print "\tOpens: ", domain['opens']
			print "\tClicks: ", domain['clicks']
			
Exemple #27
0
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)

username = "******"
password = "******"

retval = api.login(username, password)
if api.errorCode:
	print "Unable to get API key!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Returned API key: ", retval
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.campaignStats(cid)
if api.errorCode:
	print "Unable to load campaignStats()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Stats for ", cid
	for k,v in retval.items():
		print "\t", k, " => ", v
Exemple #29
0
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)

username = "******"
password = "******"

retval = api.apikeyExpire(username, password)
if api.errorCode:
    print "Unable to expire API key!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Returned: ", retval
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
start = 0
limit = 1000

retval = api.campaignForwardStats(cid, start, limit)
if api.errorCode:
	print "Unable to load campaignForwardStats()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	if len(retval) == 0:
		print "No stats for this campaign yet!"
	else:
		for email, detail in retval.items():
			print "E-mail: ", email
			print "\tFriend name = ", detail['friend_name']
Exemple #31
0
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!"
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)

username = "******"
password = "******"

retval = api.apikeyAdd(username, password)
if api.errorCode:
	print "Unable to add new API key!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Returned new API key: ", retval
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)
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
tag = 'MERGE_TAG'

retval = api.listMergeVarDel(id, tag)
if api.errorCode:
    print "Unable to load listMergeVarDel()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Returned: ", retval
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!"
Exemple #36
0
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)

username = "******"
password = "******"

retval = api.apikeyAdd(username, password)
if api.errorCode:
    print "Unable to add new API key!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Returned new API key: ", retval
Exemple #37
0
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.campaignPause(cid)
if api.errorCode:
    print "Unable to load campaignPause()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Campaign Paused!"
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
start = 0
limit = 1000

retval = api.campaignUnsubscribes(cid, start, limit)
if api.errorCode:
	print "Unable to load campaignUnsubscribes()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "E-mails returned: %d" % (len(retval))
	for email in retval:
		print "\t", email
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!"
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.campaignGeoOpens(cid)
if api.errorCode:
	print "Unable to load campaignGeoOpens()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Open from %d countries:" % (len(retval))
	for country in retval:
		print "\t", country['code'], "\t", country['name'], "\t", country['opens']
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
start = 0
limit = 1000

retval = api.campaignHardBounces(cid, start, limit)
if api.errorCode:
	print "Unable to load campaignHardBounces()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "E-mails returned: %d" % (len(retval))
	for email in retval:
		print "\t", email
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)

email_address = my_email

retval = api.listsForEmail(email_address)
if api.errorCode:
	print "Unable to get lists ID!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Returned: "
	if isinstance(retval, dict):
		for id in retval.items():
			print "\tID = ", id
	elif isinstance(retval, list):
		for id in retval:
			print "\tID = ", id
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!"
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
status = "subscribed"
start = 0
limit = 500

retval = api.listMembers(id, status, start, limit)
if api.errorCode:
	print "Unable to load listMembers()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Members returned: ", len(retval)
	if isinstance(retval, dict):
		for member in retval.items():
			print "\t%s - %s" % (member['email'], member['timestamp'])
	elif isinstance(retval, list):
		for member in retval:
			print "\t%s - %s" % (member['email'], member['timestamp'])
Exemple #45
0
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
email_address = my_email
delete_member = False
send_goodbye = True
send_notify = False

retval = api.listUnsubscribe(id, email_address, delete_member, send_goodbye,
                             send_notify)
if api.errorCode:
    print "Unable to load listUnsubscribe()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Returned: ", retval
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
tag = 'MERGE_TAG'
options = {
	"req": False,
	"name": 'Merge Tag name',
	"default_value": 'Default value',
	"show": True
}

retval = api.listMergeVarUpdate(id, tag, options)
if api.errorCode:
	print "Unable to load listMergeVarUpdate()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Returned: ", retval
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!"
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
email_address = my_email
delete_member = False
send_goodbye = True
send_notify = False

retval = api.listUnsubscribe(id, email_address, delete_member, send_goodbye, send_notify)
if api.errorCode:
	print "Unable to load listUnsubscribe()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Returned: ", retval
Exemple #49
0
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
start = 0
limit = 1000

retval = api.campaignUnsubscribes(cid, start, limit)
if api.errorCode:
    print "Unable to load campaignUnsubscribes()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "E-mails returned: %d" % (len(retval))
    for email in retval:
        print "\t", email
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']
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.campaignEmailDomainPerformance(cid)
if api.errorCode:
    print "Unable to load campaignEmailDomainPerformance()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    if len(retval) == 0:
        print "No Email Domain stats yet!"
    else:
        for domain in retval:
            print domain['domain']
            print "\tEmails: ", domain['emails']
            print "\tOpens: ", domain['opens']
            print "\tClicks: ", domain['clicks']
Exemple #52
0
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
email_address = my_email

retval = api.listMemberInfo(id, email_address)
if api.errorCode:
    print "Unable to load listMemberInfo()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    for k, v in retval.items():
        if isinstance(v, dict):
            #handle the merges
            for l, w in v.items():
                print "\t", l, " = ", w
        elif isinstance(v, list):
            #handle the merges
            for l, w in enumerate(v):
                print "\t", l, " = ", w
        else:
            print k, " = ", v
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

retval = api.listMergeVars(id)
if api.errorCode:
	print "Unable to load listMergeVars()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Merge tags returned: ", len(retval)
	if isinstance(retval, dict):
		for i,var in retval.items():
			print "Var #%d:" % (i)
			print "\tTag: ", var['tag']
			print "\tName: ", var['name']
			print "\tRequired: ", var['req']
	elif isinstance(retval, list):
		for i,var in enumerate(retval):
			print "Var #%d:" % (i)
			print "\tTag: ", var['tag']
			print "\tName: ", var['name']
			print "\tRequired: ", var['req']
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.getAccountDetails()

if api.errorCode:
	print "Unable to get account info!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Returned"
	for key,value in retval.items():
		if isinstance(value, dict):
			print "\t", key
			for k,v in value.items():
				if isinstance(v, dict):
					print "\t\t%d" % (k + 1)
					for k_,v_ in v.items():
						print "\t\t\t", k_, " = ", v_
				elif isinstance(v, list):
					print "\t\t%d" % (k + 1)
					for k_,v_ in enumerate(v):
						print "\t\t\t", k_, " = ", v_
				else:
					print "\t\t", k, " = ", v
		elif isinstance(value, list):
			print "\t", key
			for k,v in enumerate(value):
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
status = "subscribed"
start = 0
limit = 500

retval = api.listMembers(id, status, start, limit)
if api.errorCode:
    print "Unable to load listMembers()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Members returned: ", len(retval)
    if isinstance(retval, dict):
        for member in retval.items():
            print "\t%s - %s" % (member['email'], member['timestamp'])
    elif isinstance(retval, list):
        for member in retval:
            print "\t%s - %s" % (member['email'], member['timestamp'])
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.campaignClickStats(cid)
if api.errorCode:
    print "Unable to load campaignClickStats()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    if len(retval) == 0:
        print "No stats for this campaign yet!"
    else:
        for url, detail in retval.items():
            print "URL: %s" % (url)
            print "\tClicks = %s" % (detail['clicks'])
            print "\tUnique Clicks = %s" % (detail['unique'])
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
email_address = my_email
merge_vars = {"FNAME": 'Richard', "LNAME": 'Wright'}
email_type = 'html'

retval = api.listUpdateMember(id, email_address, merge_vars, email_type)
if api.errorCode:
	print "Unable to load listUpdateMember()!"
	print "\tCode=", api.errorCode
	print "\tMsg=", api.errorMessage
else:
	print "Returned: ", retval
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
start = 0
limit = 25

retval = api.campaignBounceMessages(cid, start, limit)
if api.errorCode:
    print "Unable to load campaignBounceMessages()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Messages returned: %d" % (len(retval))
    for msg in retval:
        print "%s - %s" % (msg['date'], msg['email'])
        print msg['message'][0:150]