My favorites | Sign in
Project Logo
                
Search
for
Updated Sep 30, 2008 by gr...@zum.io
Labels: Featured
CodeSample  
A quick-and-dirty sample of usage

Usage

>>> from campaignmonitorapi import CampaignMonitorApi
>>> cm = CampaignMonitorApi("YOUR API KEY", None)
>>> listid = 12345
>>> email = "nowhere@gmail.com"
>>> name = "Grant"
>>> cm.add(listid, email, name)
True

Exceptions

A CampaignMonitorApi.CampaignMonitorApiException is thrown if Campaign Monitor returns an exception.

"OK" return codes are ignored. The returned code is currently not included in the exception - the message is passed to the exception.

Tips

One gotcha to keep in mind - when you "add", the email address goes into the standard verification loops at Campaign Monitor. So, if you're set to double-opt-in, you'll need to click the link in the resultant confirmation email before calling the get_is_subscribed() method. (It will return False until you've verified.)

Another thing to note is that the add() and add_and_resubscribe() methods both support custom fields. Rather than map directly to the CM API (where the custom fields options are via separate methods), the Python API has just the two methods. If you pass custom fields, the correct CM API method will be called.


Sign in to add a comment
Hosted by Google Code